288 传统题

[CF1208D] 前缀小于之和还原排列 (Restore Permutation)

时间限制
2000ms
内存限制
256MiB
登顶 / 尝试
0/ 0
难度
4

[CF1208D] 前缀小于之和还原排列 (Restore Permutation)

Problem Statement

Let pp be a permutation of integers 11 through nn. For each 1≤i≤n1 \le i \le n, let sis_i be the sum of all elements pjp_j with j<ij < i and pj<pip_j < p_i.

Given the valid array s1,…,sns_1, \dots, s_n, reconstruct the unique permutation pp.

Input

The first line contains nn (1≤n≤2⋅1051 \le n \le 2 \cdot 10^5). The second line contains nn integers s1,…,sns_1, \dots, s_n. It is guaranteed that a valid permutation pp exists.

Output

Print nn integers p1,…,pnp_1, \dots, p_n.

Example

4
0 0 2 0
4 2 3 1

Note