Under construction

Still being built. Things may change

Permutation

Time limit0.5sMemory limit512 MB

Summary
Reconstruct a permutation of 1..N from A[i], the count of larger elements appearing before i, typically using a Fenwick tree or BIT with binary search.
Level

Medium6 of 10

Topics
Segment tree, Binary search, Math
Solved
No attempts yet

Problem

A permutation contains each integer from 1 through N exactly once. For a value i, define A[i] as the number of elements greater than i that appear before i in the permutation. Given all values A[i], reconstruct the original permutation.

Input

The first line contains the length N of the permutation (1 ≤ N ≤ 100,000). The next N lines contain A[i] for i=1,2,...,N in order, one value per line.

Output

Print the original permutation in order over N lines. The k-th line must contain the k-th element of the permutation.

Examples1

  1. Example 1

    Input
    8
    5
    0
    1
    2
    1
    2
    0
    0
    
    Expected output
    2
    7
    3
    5
    4
    1
    8
    6