#ARC069C. [ARC069E] Frequency

[ARC069E] Frequency

Score : 700700 points

Problem Statement

Snuke loves constructing integer sequences.

There are NN piles of stones, numbered 11 through NN. The pile numbered ii consists of aia_i stones.

Snuke will construct an integer sequence ss of length ai\sum a_i, as follows:

  1. Among the piles with the largest number of stones remaining, let xx be the index of the pile with the smallest index. Append xx to the end of ss.
  2. Select a pile with one or more stones remaining, and remove a stone from that pile.
  3. If there is a pile with one or more stones remaining, go back to step 1. Otherwise, terminate the process.

We are interested in the lexicographically smallest sequence that can be constructed. For each of the integers 1,2,3,...,N1,2,3,...,N, how many times does it occur in the lexicographically smallest sequence?

Constraints

  • 1N1051 \leq N \leq 10^{5}
  • 1ai1091 \leq a_i \leq 10^{9}

Input

The input is given from Standard Input in the following format:

NN

a1a_1 a2a_2 ...... aNa_{N}

Output

Print NN lines. The ii-th line should contain the number of the occurrences of the integer ii in the lexicographically smallest sequence that can be constructed.

2
1 2
2
1

The lexicographically smallest sequence is constructed as follows:

  • Since the pile with the largest number of stones remaining is pile 22, append 22 to the end of ss. Then, remove a stone from pile 22.
  • Since the piles with the largest number of stones remaining are pile 11 and 22, append 11 to the end of ss (we take the smallest index). Then, remove a stone from pile 22.
  • Since the pile with the largest number of stones remaining is pile 11, append 11 to the end of ss. Then, remove a stone from pile 11.

The resulting sequence is (2,1,1)(2,1,1). In this sequence, 11 occurs twice, and 22 occurs once.

10
1 2 1 3 2 4 2 5 8 1
10
7
0
4
0
3
0
2
3
0