N=int(eval(input()))

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



tmp=-1

idx=0

count=1

flag=True

ans=[]

while(len(b)):

    #print(idx)

    if idx<len(b):

        if b[idx]==count:

            tmp=idx

            idx+=1

            count+=1

        else:

            idx+=1

            count+=1

    if idx>(len(b)-1):

        if tmp==-1:

            flag=False

            break

        else:

            #print(tmp)

            ans.append(b[tmp])

            del b[tmp]

            tmp=-1

            idx=0

            count=1

#print(ans)

if flag:

    for i in range(len(ans)):

        print((ans[len(ans)-1-i]))

else:

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

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



ans = []

for i in range(N):

    for j in range(len(b)-1,-1,-1):

        if b[j]==(j+1):

            ans += [b[j]]

            del b[j]

            break

if len(b)!=0:

    print((-1))

    exit()



for i in range(N):

    print((ans[N-1-i]))
N = int(eval(input()))
b = list(map(int, input().split()))
tmp = -1
idx = 0
count = 1
flag = True
ans = []
while len(b):
    # print(idx)
    if idx < len(b):
        if b[idx] == count:
            tmp = idx
            idx += 1
            count += 1
        else:
            idx += 1
            count += 1
    if idx > (len(b) - 1):
        if tmp == -1:
            flag = False
            break
        else:
            # print(tmp)
            ans.append(b[tmp])
            del b[tmp]
            tmp = -1
            idx = 0
            count = 1
# print(ans)
if flag:
    for i in range(len(ans)):
        print((ans[len(ans) - 1 - i]))
else:
    print((-1))

N = int(eval(input()))
b = list(map(int, input().split()))
ans = []
for i in range(N):
    for j in range(len(b) - 1, -1, -1):
        if b[j] == (j + 1):
            ans += [b[j]]
            del b[j]
            break
if len(b) != 0:
    print((-1))
    exit()
for i in range(N):
    print((ans[N - 1 - i]))

-tmp = -1 -idx = 0 -count = 1 -flag = True -while len(b): -    # print(idx) -    if idx < len(b): -        if b[idx] == count: -            tmp = idx -            idx += 1 -            count += 1 -        else: -            idx += 1 -            count += 1 -    if idx > (len(b) - 1): -        if tmp == -1: -            flag = False +for i in range(N): +    for j in range(len(b) - 1, -1, -1): +        if b[j] == (j + 1): +            ans += [b[j]] +            del b[j] -        else: -            # print(tmp) -            ans.append(b[tmp]) -            del b[tmp] -            tmp = -1 -            idx = 0 -            count = 1 -# print(ans) -if flag: -    for i in range(len(ans)): -        print((ans[len(ans) - 1 - i])) -else: +if len(b) != 0: +    exit() +for i in range(N): +    print((ans[N - 1 - i]))