#!/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)

#!/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)

#!/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)

#!/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)

-#!/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()) +#!/bin/env python3 +IS = lambda: int(input()) +IA = lambda: [int(x) for x in input().split()] +N = IS() -sys.setrecursionlimit(500) -    if n == 0: -        return [] -    for i, x in enumerate(b, 1): -        if i < x or n < x: +    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: -    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 +    return list(reversed(ans))