문제2395--Polycarpus

### 2395: Polycarpus

실행시간 제한: 1 Sec  메모리사용 제한: 128 MB
제출: 4  통과: 3
[제출] [채점기록] [묻고답하기]

#### 문제 설명

Polycarp has $n$ dice $d_1, d_2, \dots , d_n$. The $i$-th dice shows numbers from 1 to $d_i$. Polycarp rolled all the dice and the sum of numbers they showed is A. Agrippina didn't see which dice showed what number, she knows only the sum A and the values $d_1, d_2, \dots , d_n$. However, she finds it enough to make a series of statements of the following type: dice $i$ couldn't show number $r$. For example, if Polycarp had two six-faced dice and the total sum is A = 11, then Agrippina can state that each of the two dice couldn't show a value less than five (otherwise, the remaining dice must have a value of at least seven, which is impossible). For each dice find the number of values for which it can be guaranteed that the dice couldn't show these values if the sum of the shown values is A.

#### 입력 설명

The first line contains two integers $n, A (1 \leq n \leq 2*10^5, n \leq A \leq s)$ — the number of dice and the sum of shown values where $s = d_1 + d_2 + \dots + d_n$. The second line contains $n$ integers $d_1, d_2, \dots , d_n (1 \leq d_i \leq 10^6)$, where $d_i$ is the maximum value that the $i$-th dice can show.

#### 출력 설명

Print $n$ integers $b_1, b_2, \dots , b_n$, where $b_i$ is the number of values for which it is guaranteed that the $i$-th dice couldn't show them.

#### 입력 예시 Copy

2 3
2 3


#### 출력 예시 Copy

0 1


#### 도움

In sample from the statement A equal to 3 could be obtained when one dice shows 1 and the other dice shows 2. That's why the first dice doesn't have any values it couldn't show and the second dice couldn't show 3.