CodeEff/ECCO huggingface dataset:
# Original solution
n = int(eval(input()))
b = list(map(int, input().split()))
for i in range(n):
  if b[i] > i+1:
    print((-1))
    break
else:
  ans = []
  while len(b) > 1:
#    print(ans,b)
    c = len(ans)
    f = b[0]
    for i in range(1, len(b))[::-1]:
      if b[i] == i + 1:
#        print("check", b[i:])
        ans.append(b.pop(i))
        break
    else:
      for i in range(1, len(b)):
#      print(f, i, b, n - c, ans)
        if f >= b[i]:
          ans.append(b.pop(i-1))
          break
        elif n - c == b[i]:
          ans.append(b.pop(i))
          break
        elif i == len(b) - 1:
          ans.append(b.pop(-1))
          break
        else:
          f = b[i]
  ans.append(1)
  for i in range(n)[::-1]:
    print((ans[i]))

# Optimized solution
n = int(eval(input()))
b = list(map(int, input().split()))
for i in range(n):
  if b[i] > i+1:
    print((-1))
    break
else:
  ans = []
  while len(b) > 0:
    f = b[0]
    for i in range(len(b))[::-1]:
      if b[i] == i + 1:
        ans.append(b.pop(i))
        break

  for i in range(n)[::-1]:
    print((ans[i]))
# Original solution
N = int(eval(input()))
B = list(map(int, input().split()))

def dfs(stack, B):
    if len(B)==1:
        if B[0]==1:
            stack.append(1)
            return stack
        else: return None
    else:
        tmp = []
        flag = False
        for i, b in enumerate(B):
            stack_ = stack + [b]
            B_ = B[:i] + B[i+1:]
            if b==i+1: tmp.append(dfs(stack_, B_))
        for tp in tmp:
            if tp is not None:
                flag = True
                ans = tp
        if flag:
            return ans
        else:
            return None
ans = dfs([], B)
if ans is None:
    print('-1')
else:
    ans = ans[::-1]
    for i in range(N):
        print((ans[i]))

# Optimized solution
N = int(eval(input()))
B = list(map(int, input().split()))

stack = []
for i in range(N):
    tmp = []
    flag = True
    for j in range(len(B)):
        if B[j]==j+1:
            tmp.append(j)
    if tmp:
        tmp.sort(reverse=True)
        ans = tmp[0]
        B = B[:ans] + B[ans+1:]
        stack.append(ans+1)
    else:
        flag = False
        break
if flag:
    stack = stack[::-1]
    for i in stack:
        print(i)
else:
    print((-1))
# Original solution
import sys
import time
import copy

N = int(eval(input()))
b = [int(b) for b in input().split()]
h = {}

t1 = time.time()

def f(b):
  t2 = time.time()
  if t2 - t1 > 1.9:
    print((-1))
    sys.exit()
  
  key = "".join([str(x) for x in b])
  if key in h:
    return copy.copy(h[key])
  
  if len(b) == 1:
    h[key] = b if b[0] == 1 else []
    return copy.copy(h[key])
  
  for i in range(len(b)):
    i = len(b) - 1 - i
    if b[i] == i + 1:
      b_sub = copy.copy(b)
      b_i = b_sub.pop(i)
      a = f(b_sub)
      if len(a) != 0:
        a.append(b_i)
        h[key] = a
        return copy.copy(h[key])
  
  h[key] = []
  return copy.copy(h[key])

a = f(b)
if len(a) == 0:
  print((-1))
else:
  for i in range(N):
    print((a[i]))

# Optimized solution
import sys
import time
import copy

N = int(eval(input()))
b = [int(b) for b in input().split()]
h = {}

t1 = time.time()

def f(b):
  t2 = time.time()
  if t2 - t1 > 1.5:
    print((-1))
    sys.exit()
  
  key = "".join([str(x) for x in b])
  if key in h:
    return copy.copy(h[key])
  
  if len(b) == 1:
    h[key] = b if b[0] == 1 else []
    return copy.copy(h[key])
  
  for i in range(len(b)):
    i = len(b) - 1 - i
    if b[i] == i + 1:
      b_sub = copy.copy(b)
      b_i = b_sub.pop(i)
      a = f(b_sub)
      if len(a) != 0:
        a.append(b_i)
        h[key] = a
        return copy.copy(h[key])
  
  h[key] = []
  return copy.copy(h[key])

a = f(b)
if len(a) == 0:
  print((-1))
else:
  for i in range(N):
    print((a[i]))
# Original solution
LIST=""
LIST=list(LIST)
c=0

def func(S):
    global LIST
    global c

    if(len(S)==0):
        c=1
    if(c==1):
        for i in range(len(LIST)-1,-1,-1):
            print((LIST[i]))
        exit()

    So=S[::]
    for i in range(len(S)):
        S=So[::]
        if(S[i]==(i+1)):
            LIST.append(S.pop(i))
            func(S)
    if(len(LIST)==0):
        print("-1")
        exit()
    LIST.pop(-1)

N=int(eval(input()))
S=list(map(int,input().split()))

for i in range(N):
    if((S[i] - i)>1):
        print("-1")
        exit()  

func(S)
print("-1")

# Optimized solution
N=int(eval(input()))
S=list(map(int,input().split()))
LIST=list("")

for i in range(N):
    if((S[i] - i)>1):
        print("-1")
        exit()  

while(len(S)>0):
    c=10**10
    for i in range (len(S)):
        if(S[i]==i+1):
            c=i
    if(c==(10**10)):
        print("-1")
        exit()  
    LIST.append(S.pop(c))

for i in range(len(LIST)-1,-1,-1):
    print((LIST[i]))
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))

def solve(l, ans):
	if l == []:
		return ans

	cnd = [] 
	for i in range(len(l)):
		if l[i] == i+1:
			cnd.append(i)

	if cnd == []:
		return 0

	for ind in cnd:
		ans.append(ind+1)
		cond = solve(l[0:ind] + l[(ind+1):(len(l)+1)], ans)
		if cond == 0:
			ans.pop()
			continue
		else:
			return cond


	return 0	

ans = solve(a,[])

if ans == 0:
	print((-1))
else:
	for A in ans[::-1]:
		print(A)

# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split()))

def solve(l,ans):
	if l == []:
		return ans
	for i in range(len(l)-1,-1,-1):
		if l[i] == i+1:
			ans.append(i+1)
			return solve(l[:i]+l[i+1:], ans)

	return 0


A = solve(a,[])
if A == 0:
	print((-1))
else:
	for a in A[::-1]:
		print(a)
# Original solution
def limited_insertion(N: int, B: list)->list:
    # print(N, B)
    if N == 1:
        return [1] if B[0] == 1 else []
    # 後ろからみていって、インデックス(1-indexed)と
    # その位置の配列(B)の値が等しい最初のペアを探す。
    # なければ失敗
    for i in range(N, 0, -1):
        if i == B[i-1]:
            # 見つけたら、それを除いた配列に関して
            # 再帰的に同じことを行う。
            # print('>>>pair', i, B[i-1])
            rec = limited_insertion(N-1, B[:i-1] + B[i:])
            if len(rec) > 0:
                return rec + [i]
            else:
                return []

    return []


if __name__ == "__main__":
    N = int(eval(input()))
    B = [int(s) for s in input().split()]
    A = limited_insertion(N, B)
    if len(A) == 0:
        print((-1))
    else:
        for a in A:
            print(a)


# Optimized solution
def limited_insertion(N: int, B: list) -> list:
    op = []
    for i in range(N-1, -1, -1):
        for j in range(i, -1, -1):
            b = B[j]
            if i+1 < b:
                # invalid number
                return []
            if j+1 == b:
                # remove b[j]
                B = B[:j] + B[j+1:]
                op.append(b)
                break
        else:
            # not found
            return []
    return reversed(op)


if __name__ == "__main__":
    N = int(eval(input()))
    B = [int(s) for s in input().split()]

    ans = limited_insertion(N, B)
    if ans:
        for a in ans:
            print(a)
    else:
        print((-1))
# Original solution
import copy

def dfs(i, operations, rest_bs):
    if i == 0 and len(rest_bs) == 0:
        return operations

    for k, b in enumerate(rest_bs):
        j = k + 1
        if j <= i and j == b:
            copied_operations = copy.deepcopy(operations)
            copied_operations.append(j)
            res = dfs(i-1, copied_operations, rest_bs[:k] + rest_bs[k+1:])
            if res != -1:
                return res
    return -1


if __name__ == "__main__":
    N = int(eval(input()))
    bs = list(map(int, input().split()))

    res = dfs(N, [], bs)
    if res == -1:
        print((-1))
    else:
        for n in reversed(res):
            print(n)


# Optimized solution
if __name__ == "__main__":
    N = int(eval(input()))
    bs = list(map(int, input().split()))

    operations = []
    for i in range(N):
        j_remove = -1
        for j in range(N-i):
            if bs[j] == j+1:
                j_remove = j
        if j_remove == -1:
            print("-1")
            exit()
        operations.append(bs.pop(j_remove))
    for n in reversed(operations):
        print(n)
# Original solution
N = int(eval(input()))
b = list(map(int, input().split()))

def dfs(c):
  if len(c) == 0:
    return []

  for i in range(1, len(c)+1):
    if c[i-1] > i:
      return False

    if c[i-1] == i:
      cc = c.copy()
      del cc[i-1]
      res = dfs(cc)
      if res is not False:
        res.append(i)
        return res

  return False

res = dfs(b)
if res is False:
  print((-1))
else:
  for i in res:
    print(i)

# Optimized solution
N = int(eval(input()))
b = list(map(int, input().split()))

def dfs(c):
  if len(c) == 0:
    return []

  for i in range(len(c), 0, -1):
    if c[i-1] > i:
      return False

    if c[i-1] == i:
      cc = c.copy()
      del cc[i-1]
      res = dfs(cc)
      if res is not False:
        res.append(i)
        return res

  return False

res = dfs(b)
if res is False:
  print((-1))
else:
  for i in res:
    print(i)
# Original solution
import sys
from collections import Counter


def input():
    return sys.stdin.readline().strip()
# sys.setrecursionlimit(100000)


def helper(cur: list, B, candi, ans, rest):
    if rest == 0:
        if cur == B:
            for i in ans:
                print(i)
            sys.exit()
        else:
            return
    for k, v in list(candi.items()):
        if v > 0 and len(cur) + 1 >= k:
            cur.insert(k - 1, k)

            candi[k] -= 1
            helper(cur, B, candi, ans + [k], rest - 1)
            cur.pop(k - 1)
            candi[k] += 1


def main():
    n = int(input().strip())
    B = [int(i) for i in input().strip().split()]
    counter = Counter(B)
    helper([], B, counter, [], n)
    print((-1))
    return


if __name__ == "__main__":
    main()


# Optimized solution
import sys


def input():
    return sys.stdin.readline().strip()
# sys.setrecursionlimit(100000)


def main():
    n = int(input().strip())
    B = [int(i) for i in input().strip().split()]
    ans = []
    ptr = len(B)
    while ptr > 0:
        if B[ptr - 1] == ptr:
            ans.append(B.pop(ptr - 1))
            ptr = len(B)
        else:
            ptr -= 1
    if len(ans) == n:
        for i in ans[::-1]:
            print(i)
    else:
        print((-1))

    return


if __name__ == "__main__":
    main()
# Original solution
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))

# Optimized solution
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)
# Original solution
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
from itertools import chain
from functools import reduce
from collections import OrderedDict, Counter, deque
import operator


def IA(): return [int(x) for x in input().split()]


def IM(N): return [IA() for _ in range(N)]


N = int(input())
B = IA()

sys.setrecursionlimit(500)


def f(b, n):
    if n == 0:
        return []
    for i, x in enumerate(b, 1):
        if i < x or n < x:
            return None
    for i, x in enumerate(b, 1):
        if i == x:
            ret = f(tuple(b[:i-1] + b[i:]), n-1)
            if ret is not None:
                return ret + [i]
    return None


ans = f(B, N)
if ans:
    print(*ans, sep="\n")
else:
    print(-1)


# Optimized solution
#!/bin/env python3

IS = lambda: int(input())
IA = lambda: [int(x) for x in input().split()]

N = IS()
B = IA()

def f(b, n):
    ans = []
    while b:
        for i in range(len(b), 0, -1):
            j = i - 1
            if i == b[j]:
                ans.append(i)
                b = b[:j] + b[j+1:]
                break
        else:
            return None
    return list(reversed(ans))

ans = f(B, N)
if ans:
    print(*ans, sep="\n")
else:
    print(-1)
# Original solution
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))

# Optimized solution
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]))
# Original solution
def main():
  if 'get_ipython' not in globals():  
    # For Subsession
    N = int(eval(input()))
    # b = list(map(int, input().split()))
    b = [int(i) for i in input().split()] 
  else:
    # b = [1,2,1]
    # b = [2,2]
    b = [1,1,1,2,2,1,2,3,2]
    N = len(b)
  
  if check(b,N) != True:
    print((-1))
    
def check(B,lenB):
  # if 'get_ipython' in globals(): print(B)
  if lenB == 0 :
    return True
  #for i in reversed(range(lenB)):
  for i in range(lenB-1,-1,-1):
    if B[i] == i+1:
      if check(B[:i]+B[(i+1):],lenB -1 ) == True:
        print((B[i]))
        return True
        break
  return False  

main()

# Optimized solution
import sys

def main():
  if 'get_ipython' not in globals():  
    # For Subsession
    N = int(eval(input()))
    b = [int(i) for i in input().split()] 
  else:
    # b = [1,2,1]
    # b = [2,2]
    b = [1,1,1,2,2,1,2,3,2]
    N = len(b)

  ans = []
  while True:
    for i in range(N-1,-1,-1):
      if b[i] == i+1:
        ans.append(i+1)
        del b[i]
        N = N -1
        break
      if i == 0:
        print((-1))
        sys.exit()
    if N == 0:
      break

  for i in reversed(ans):
    print(i)
    
main()
# Original solution
N=int(eval(input()))
B=list(map(int,input().split(' ')))
def dfs(n,B,ans):
    if n==0:
        return ans[::-1]
    else:
        for num,i in enumerate(B):
            if num+1==i:
                res = dfs(n-1,B[:num]+B[num+1:],ans+[i])
                if res:
                    return res
        return False
ans = dfs(N,B,[])
if not ans:
    print((-1))
else:
    for i in ans:
        print(i)

# Optimized solution
N=int(eval(input()))
B=list(map(int,input().split(' ')))
ans = []
for i in range(N):
    for n,j in enumerate(B[::-1]):
        if N-i-n==j:
            ans.append(B.pop(N-i-n-1))
            break
if len(ans)==N:
    for i in ans[::-1]:
        print(i)
else:
    print((-1))
# Original solution
N = int(eval(input()))
b_list = list(map(int, input().split()))

generate_seq = []


def is_ok(b):
    len_b = len(b)
    if len_b == 1 and b[0] == 1:
        generate_seq.append(1)
        return True

    processing = []
    for idx in range(len_b):
        if b[idx] != idx + 1:
            processing.append(False)
        else:
            b_tmp = b[:]
            del b_tmp[idx]
            tmp = is_ok(b_tmp)
            if tmp:
                generate_seq.append(idx + 1)
                return True
    return False


result = is_ok(b_list)
if result:
    print(('\n'.join(list(map(str, generate_seq)))))
else:
    print((-1))


# Optimized solution
N = int(eval(input()))
b_list = list(map(int, input().split()))

generate_seq = []


def is_ok(b):
    len_b = len(b)
    if len_b == 1 and b[0] == 1:
        generate_seq.append(1)
        return True

    for idx, val in enumerate(b):
        if idx + 1 < val:
            return False

    processing = []
    for idx in range(len_b):
        if b[idx] != idx + 1:
            processing.append(False)
        else:
            b_tmp = b[:]
            del b_tmp[idx]
            tmp = is_ok(b_tmp)
            if tmp:
                generate_seq.append(idx + 1)
                return True
    return False


result = is_ok(b_list)
if result:
    print(('\n'.join(list(map(str, generate_seq)))))
else:
    print((-1))
# Original solution
import sys
sys.setrecursionlimit(10**6)

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

def dfs(s, ans):
    #print(s, ans)
    if len(s) == 0:
        print(('\n'.join(map(str, reversed(ans)))))
        exit()
        return
    for i in range(len(s)):
        if s[i] == i+1:
            s1 = s[:i] + s[i+1:]
            ans.append(s[i])
            dfs(s1, ans)
    if len(ans) > 0:
        ans.pop()

dfs(b, [])

print('-1')


# Optimized solution
import sys
sys.setrecursionlimit(10**6)

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

def dfs(s, ans):
    if len(s) == 0:
        print(('\n'.join(map(str, reversed(ans)))))
        exit()
        return
    for i in range(len(s)):
        #if s[i] == i+1:
        #if s[i] == i+1 and max(s[:i] + [0]) >= i:
        if s[i] == i+1:
            s1 = s[:i] + s[i+1:]
            allok = True
            for j in range(len(s1)):
                if s1[j] > j+1:
                    allok = False
                    break
            #print(s[:i], s[i+1:],i)
            if allok:
                ans.append(s[i])
                dfs(s1, ans)
    if len(ans) > 0:
        ans.pop()

dfs(b, [])

print('-1')
# Original solution
import sys
sys.setrecursionlimit(10**6)

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

def dfs(s, ans):
    if len(s) == 0:
        print(('\n'.join(map(str, reversed(ans)))))
        exit()
        return
    for i in range(len(s)):
        #if s[i] == i+1:
        #if s[i] == i+1 and max(s[:i] + [0]) >= i:
        if s[i] == i+1:
            s1 = s[:i] + s[i+1:]
            allok = True
            for j in range(len(s1)):
                if s1[j] > j+1:
                    allok = False
                    break
            #print(s[:i], s[i+1:],i)
            if allok:
                ans.append(s[i])
                dfs(s1, ans)
    if len(ans) > 0:
        ans.pop()

dfs(b, [])

print('-1')


# Optimized solution
n = int(eval(input()))
b = list(map(int , input().split()))

def f(c):
    for i in reversed(list(range(len(c)))):
        if c[i] == i+1:
            return (c[i], c[:i] + c[i+1:])
    return (-1, c)

ans = []
for i in range(n):
    (a, b) = f(b)
    if a == -1:
        print((-1))
        exit()
    ans.append(a)
    #print(ans, b)

print(('\n'.join(map(str, reversed(ans)))))
# Original solution
import sys
sys.setrecursionlimit(2147483647)
INF=float('inf')
MOD=10**9+7
input=sys.stdin.readline

n=int(eval(input()))
s=list(map(int,input().split()))
import copy
def DEF(ary,ary2):
    #print(ary,ary2)
    global n,s
    if len(ary2)==n:
        #print(ary)
        if ary==s:
            for item in ary2:
                print(item)
            exit()
    else:
        for i in range(len(ary)+1):
            tmp = copy.deepcopy(ary)
            tmp.insert(i,i+1)
            DEF(tmp,ary2+[i+1])

DEF([],[])
print((-1))


# Optimized solution
n=int(eval(input()))
s=list(map(int,input().split()))


result=[]

for i in range(n):
    posi=-1
    for index,ss in enumerate(s):
        if ss==index+1:
            posi=index
    if posi==-1:
        print((-1))
        exit()
    else:
        result.append(s[posi])
        s.pop(posi)

for item in result[::-1]:
    print(item)
# Original solution
n=int(eval(input()))
b=list(map(int,input().split()))
a=[0]*(n+1)
a[0]=0
for i in b:a.insert(int(i)-1,i)
if sum(a[:n])==sum(b):
    for i in range(n):
        print((a[i]))
else:print((-1))

# Optimized solution
n=int(eval(input()))
B=list(map(int,input().split()))
a=[0]
for b in B:a.insert(b-1,b)
if sum(a[:n])==sum(B):
    for i in range(n):print((a[i]))
else:print((-1))
# Original solution
N = int(eval(input()))
b = [int(_) for _ in input().split()]


def delitable(numbers):
    return [v for i, v in enumerate(numbers) if v == i + 1]


b_searched = set()
b_unsearched = []


b_searched.add(tuple(b))
delit = delitable(b)

if delit == []:
    print("-1")
for delit_num in delit:
    b_unsearched.append([b[:delit_num - 1] + b[delit_num:], [delit_num]])


while b_unsearched:
    b, log = b_unsearched.pop()

    if b and max(b) > N - len(log):
        continue

    b_tuple = tuple(b)
    b_searched.add(b_tuple)
    delit = delitable(b)


    if not delit:
        if not b:
            log.reverse()
            print(("\n".join(map(str, log))))
            break
        else:
            continue
    for delit_num in delit:
        b_temp = b[:delit_num - 1] + b[delit_num:]
        if not tuple(b_temp) in b_searched:
            b_unsearched.append([b_temp, log + [delit_num]])
else:
    print("-1")

# Optimized solution
N = int(eval(input()))
b = [int(_) for _ in input().split()]


def delitable(numbers):
    return [v for i, v in enumerate(numbers) if v == i + 1]


log = []
while b:
    delit = delitable(b)
    if not delit:
        print((-1))
        break
    del b[delit[-1] - 1]
    log.append(delit[-1])
else:
    log.reverse()
    print(("\n".join(map(str, log))))
# Original solution
def solve(remains, nums):
    if (len(remains)) == 0:
        [print(num) for num in nums[::-1]]
        exit()
    n_remains = []
    n_nums = []
    for i, num in enumerate(remains):
        if i + 1 == num:
            n_remains.append(remains[:i] + remains[i + 1:])
            n_nums.append(nums + [i + 1])
    if len(n_remains) == 0:
        return False
    for n_remain, n_num in zip(n_remains, n_nums):
        solve(n_remain, n_num)


n = int(input())
B = [int(x) for x in input().split()]

solve(B, [])
print(-1)


# Optimized solution
def solve(remains, nums):
    if (len(remains)) == 0:
        [print(num) for num in nums[::-1]]
        exit()
    n_remain = None
    n_num = None
    for i, num in enumerate(remains):
        if i + 1 == num:
            n_remain = remains[:i] + remains[i + 1:]
            n_num = nums + [i + 1]
    if n_remain is None:
        return False
    solve(n_remain, n_num)


n = int(input())
B = [int(x) for x in input().split()]

solve(B, [])
print(-1)
# Original solution
import sys
input = sys.stdin.readline

N=int(eval(input()))
B=list(map(int,input().split()))

def dfs(B,LEN,ANS):
    #print(B,LEN,ANS)
    if LEN==0:
        for a in ANS[::-1]:
            print(a)
        sys.exit()
    for i in range(LEN):
        if B[i]==i+1:
            C=B[:i]+B[i+1:]
            dfs(C,LEN-1,ANS+[i+1])

dfs(B,N,[])
print((-1))

# Optimized solution
import sys
input = sys.stdin.readline

N=int(eval(input()))
B=list(map(int,input().split()))

for i in range(N):
    if B[i]>i+1:
        print((-1))
        sys.exit()

def dfs(B,LEN,ANS):
    #print(B,LEN,ANS)
    if LEN==0:
        for a in ANS[::-1]:
            print(a)
        sys.exit()
    for i in range(LEN-1,-1,-1):
        if B[i]==i+1:
            C=B[:i]+B[i+1:]
            dfs(C,LEN-1,ANS+[i+1])

dfs(B,N,[])
print((-1))
# Original solution
# coding: utf-8

eval(input())

B_ = [int(i) for i in input().split()]

def f (B, ans):
  if len(B) == 0:
    return ans
  for i in range(len(B)):
    if B[i] <= len(B) and B[i] == i+1 :
      B2 = B[:]
      ans2 = ans[:]
      ans2.append(B2.pop(B[i]-1))
      result = f(B2, ans2)
      if result is not None: 
        return result

result = f(B_, [])
if result is None:
  result = [-1]
for s in result[::-1]:
  print(s)

# Optimized solution
# coding: utf-8

N = int(eval(input()))

B = [int(i) for i in input().split()]

ans = []

while (len(B) > 0):
  for _ in range(len(B)):
    for i in list(range(len(B)))[::-1]:
      if B[i] == i+1:
        ans.append(i+1)
        B.pop(i)
        break
  break

if len(ans) != N:
  print((-1))
else:
  for i in ans[::-1]:
    print(i)