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')

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)))))

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")

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)))))

-import sys - -sys.setrecursionlimit(10**6) -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() +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) -dfs(b, []) -print("-1") +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)))))