Do not drag out the suspense
Limits: 2 sec., 256 MiB
This statement was translated automatically from Ukrainian.
The Olympiad has ended — the tense four hours are behind. Schoolchildren are sharing their impressions and solutions with teachers and rivals. And the most interesting thing for them to find out is how many points other participants scored in order to evaluate their chances of getting into the selection for the All-Ukrainian Olympiad in Informatics. The scoreboard, of course, does not become available immediately after the competition. Participants go to the closing ceremony together to hear the results there.
Let \(n\) be the number of participants in the Olympiad. They are numbered from 1 to \(n\). Then the scoreboard can be represented by a permutation \(p\) of numbers from 1 to \(n\). The winner of the Olympiad is the participant with number \(p_1\), the second place was taken by participant \(p_2\), the honorable bronze goes to participant \(p_3\), the lucky fourth place to participant \(p_4\), and so on.
Instead of immediately telling the participants the permutation \(p\), the organizers want to fuel the interest of young algorithmists and drag out the suspense a little longer. They calculated an array \(a\) of \(n\) elements, where element \(a_k\) is the number of inversions on the prefix of length \(k\). This is the array they will show on the projector at the closing ceremony.
Formally, for each \(k\) you are given the number of pairs of indices \((i, j)\) such that \(1 \le i < j \le k\) and \(p_i > p_j\) — the number of inversions on the prefix of length \(k\).
Zenyk and Marichka easily managed to restore the entire permutation \(p\) from the given information. Can you?
Input
The first line gives the integer \(n\) — the number of participants in the Olympiad.
The second line contains \(n\) integers \(a_k\) — the elements of array \(a\), which the organizers reported to the participants at the closing ceremony.
Output
In a single line, output \(n\) integers \(p_i\) — the permutation of participants in the scoreboard.
Constraints
\(1 \le n \le 2 \cdot 10^5\),
organizers never make mistakes, and therefore are guaranteed to have correctly calculated the elements of array \(a\).
Task scoring consists of the following blocks:
1 point — example from the statement,
9 points — \(n \le 10^3\),
15 points — without additional constraints.
You will receive points for a block only if you give the correct answer to all tests in the block.
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 5 0 1 2 4 7 | 5 1 4 3 2 |
Notes
In the example \(p=(5, 1, 4, 3, 2)\).
Pair \((3, 4)\) is an inversion because \(3<4\) and \(p_3 > p_4\) (\(p_3=4, p_4=3\)). Pair \((2, 5)\) is not an inversion because \(p_2 < p_5\) (\(p_2 = 1, p_5 = 2\)).
In total, there are seven inversions in the permutation: \((1, 2)\), \((1, 3)\), \((1, 4)\), \((1, 5)\), \((3, 4)\), \((3, 5)\), \((4, 5)\).
Prefix \((5)\) does not contain any inversions.
Prefix \((5, 1)\) contains one inversion \((1, 2)\).
Prefix \((5, 1, 4)\) contains two inversions \((1, 2)\) and \((1, 3)\).
Prefix \((5, 1, 4, 3)\) contains four inversions \((1, 2)\), \((1, 3)\), \((1, 4)\), \((3, 4)\).
The entire permutation contains seven inversions.
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|