#agc032a. [agc032_a]Limited Insertion
[agc032_a]Limited Insertion
Problem Statement
Snuke has an empty sequence .
He will perform operations on this sequence.
In the -th operation, he chooses an integer satisfying , and insert at position in (the beginning is position ).
You are given a sequence of length . Determine if it is possible that is equal to after operations. If it is, show one possible sequence of operations that achieves it.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
If there is no sequence of operations after which would be equal to , print -1
. If there is, print lines. In the -th line, the integer chosen in the -th operation should be printed. If there are multiple solutions, any of them is accepted.
Sample Input 1
3
1 2 1
Sample Output 1
1
1
2
In this sequence of operations, the sequence changes as follows:
- After the first operation:
- After the second operation:
- After the third operation:
Sample Input 2
2
2 2
Sample Output 2
-1
cannot be inserted at the beginning of the sequence, so this is impossible.
Sample Input 3
9
1 1 1 2 2 1 2 3 2
Sample Output 3
1
2
2
3
1
2
2
1
1