n=int(eval(input()))



ball = list(map(int,input().split()))



ans = []



count = 0



while len(ball)>0:

    count += 1

    for i in range(len(ball)-1,-1,-1):

        #print(ball,i)

        if i+1 ==ball[i]:

            move = ball.pop(i)

            ans.insert(0,move)

            break

    if count ==100000:

        break

    



if len(ans) == n:

    for i in ans:

        print(i)

else:

    print((-1))
n = int(eval(input()))



b = list(map(int,input().split()))



Flag = True



memo = []



while Flag:

    Flag = False

    index = -1

    for i, v in enumerate(b):

        if i == v-1:

            Flag = True

            index = i

    if index != -1:

        m = b.pop(index)

        memo.append(m)

if len(b):

    print((-1))

else:

    memo.reverse()

    for aa in memo:

        print(aa)
n = int(eval(input()))
ball = list(map(int, input().split()))
ans = []
count = 0
while len(ball) > 0:
    count += 1
    for i in range(len(ball) - 1, -1, -1):
        # print(ball,i)
        if i + 1 == ball[i]:
            move = ball.pop(i)
            ans.insert(0, move)
            break
    if count == 100000:
        break
if len(ans) == n:
    for i in ans:
        print(i)
else:
    print((-1))

n = int(eval(input()))
b = list(map(int, input().split()))
Flag = True
memo = []
while Flag:
    Flag = False
    index = -1
    for i, v in enumerate(b):
        if i == v - 1:
            Flag = True
            index = i
    if index != -1:
        m = b.pop(index)
        memo.append(m)
if len(b):
    print((-1))
else:
    memo.reverse()
    for aa in memo:
        print(aa)

-ball = list(map(int, input().split())) -ans = [] -count = 0 -while len(ball) > 0: -    count += 1 -    for i in range(len(ball) - 1, -1, -1): -        # print(ball,i) -        if i + 1 == ball[i]: -            move = ball.pop(i) -            ans.insert(0, move) -            break -    if count == 100000: -        break -if len(ans) == n: -    for i in ans: -        print(i) +b = list(map(int, input().split())) +Flag = True +memo = [] +while Flag: +    Flag = False +    index = -1 +    for i, v in enumerate(b): +        if i == v - 1: +            Flag = True +            index = i +    if index != -1: +        m = b.pop(index) +        memo.append(m) +if len(b): +    print((-1)) -    print((-1)) +    memo.reverse() +    for aa in memo: +        print(aa)