Score : $700$ points
Snuke loves constructing integer sequences.
There are $N$ piles of stones, numbered $1$ through $N$. The pile numbered $i$ consists of $a_i$ stones.
Snuke will construct an integer sequence $s$ of length $Σa_i$, as follows:
We are interested in the lexicographically smallest sequence that can be constructed. For each of the integers $1,2,3,...,N$, how many times does it occur in the lexicographically smallest sequence?
The input is given from Standard Input in the following format:
$N$ $a_1$ $a_2$ $...$ $a_{N}$
Print $N$ lines. The $i$-th line should contain the number of the occurrences of the integer $i$ in the lexicographically smallest sequence that can be constructed.
2 1 2
2 1
The lexicographically smallest sequence is constructed as follows:
The resulting sequence is $(2,1,1)$. In this sequence, $1$ occurs twice, and $2$ occurs once.
10 1 2 1 3 2 4 2 5 8 1
10 7 0 4 0 3 0 2 3 0