<PREV Problem:
NEXT>
Solved by 646 users: ...
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 

Reconstructing permutation

Time limit = 3 second(s)

Memory limit = 32000

Petya has shuffled numbers 1,2, .. N and placed them into array A[1..N]. Then he created a new array B[1..N], in which element B[i] represents the number of elements in array A with index >i that are greater than element with index i.

Given array B could you reconstruct initial array A ?

If it is possible you should output array A, otherwise output "-1" without quotes.

Input The number N (1 < N < 10000) folowed by N elements of array B.

Output Elements of array A or "-1".

Input#1
4
1 1 1 0
Output#1
3 2 1 4
Input#2
5
2 2 2 2 2
Output#2
-1
Input#3
10
0 0 0 0 0 0 0 0 0 0 
Output#3
10 9 8 7 6 5 4 3 2 1

Author:
Regional olimpiad 2001 year.
30 November 2003

<PREV | Problem set | Search related messages | NEXT>


© acm.mipt DevGroup
The page was generated in 200ms

SW soft NIX
ID = 54.80.60.91