#CCBCHBAHAI0000055. Bộ phân tích dãy số nguyên PHOJ (PHOJ Integer Sequence Analyzer)

    ID: 973 Loại: Thông thường 2000ms 256MiB Tried: 0 Đã chấp nhận: 0 Độ khó: 1 Đăng bởi: Nhãn>Programming language basicsStatic arraysIteration techniquesImplementation techniquesInteger arithmetic

Bộ phân tích dãy số nguyên PHOJ (PHOJ Integer Sequence Analyzer)

PHOJ Integer Sequence Analyzer (Bộ phân tích dãy số nguyên PHOJ)

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem

Given an integer array a0,…,an−1a_0,\ldots,a_{n-1} and a target xx, compute

S=∑ai,m=min⁡ai,M=max⁡ai,S=\sum a_i,\quad m=\min a_i,\quad M=\max a_i,

the counts N−,N0,N+N_-,N_0,N_+ of negative, zero and positive elements,

p=min⁡{i:ai=M},q=max⁡{i:ai=m},p=\min\{i:a_i=M\},\qquad q=\max\{i:a_i=m\},

and the target frequency

fx=∣{i:ai=x}∣.f_x=|\{i:a_i=x\}|.

All indices are 0-based.

Input

The first line contains nn and xx. The second line contains nn integers aia_i.

Output

Line 1: SS. Line 2: m M. Line 3: N_- N_0 N_+. Line 4: p q f_x.

Subtask

Subtask 1 (20 points): 1≤n≤101\le n\le10, ∣ai∣,∣x∣≤103|a_i|,|x|\le10^3.

Subtask 2 (30 points): 1≤n≤50001\le n\le5000, ∣ai∣,∣x∣≤106|a_i|,|x|\le10^6.

Subtask 3 (50 points): 1≤n≤2⋅1051\le n\le2\cdot10^5, ∣ai∣,∣x∣≤109|a_i|,|x|\le10^9.

Example

Input

7 2
2 -1 5 0 5 -1 2

Output

12
-1 5
2 1 4
2 5 2

Explanation

The sample follows the definitions and rules above.