cswork / OAOpen practice workspace

AmazonOA #233

Get Most Out of the Data

Estimated MediumJudge-ready

Topics (AI-labelled)GreedyIn-place Arrays

Output a permutation p of 1..n that maximizes sum(i*data[p[i]]), where i and p are both interpreted as 1-based; if several permutations tie, take the lexicographically smallest. The index range 0..n in the original formula is a typo; changing the weights to 0..n−1 only shifts the result by a fixed total and does not affect the optimal permutation.

Input

The first line contains n; the second line contains data. The original text had no numeric bounds; this site uses 1≤n≤200000, −10^9≤data≤10^9. The output is a permutation of original array indices, not the sorted values or the rank of each element.

Output

Output n 1-based original indices, separated by spaces.

Example 1

Input:

3
3 1 2

Output:

2 3 1

Example 2

Input:

3
2 2 1

Output:

3 1 2

Example 3

Input:

3
-2 -1 -2

Output:

1 3 2

Example notes

The answers are 2 3 1, 3 1 2 and 1 3 2. Equal values are ordered by ascending original index.

Editorial

Loading solution…