Farmer John's Favorite Permutation
문제
Farmer John has a permutation of length (, containing each positive integer from to exactly once. However, Farmer Nhoj has broken into FJ's barn and disassembled . To not be too cruel, FN has written some hints that will help FJ reconstruct . While there is more than one element remaining in , FN does the following:
Let the remaining elements of be ,
- If , he writes down and removes from the permutation.
- Otherwise, he writes down and removes from the permutation.
At the end, Farmer Nhoj will have written down integers , in that order. Given , Farmer John wants to enlist your help to reconstruct the lexicographically minimum consistent with Farmer Nhoj's hints, or determine that Farmer Nhoj must have made a mistake. Recall that if you are given two permutations and , is lexicographically smaller than if at the first position where the two differ.
입력
Each input consists of independent test cases (). Each test case is described as follows:
The first line contains .
The second line contains integers ().
출력
Output lines, one for each test case.
If there is a permutation of consistent with , output the lexicographically smallest such . If no such exists, output .
예제
예제 1
5 2 1 2 2 4 1 1 1 4 2 1 1 4 3 2 1
1 2 -1 -1 3 1 2 4 1 2 3 4