n = int(input())
a = list(map(int, input().split()))

# Проверка условия на n
k = (n + 1).bit_length() - 1
if n != 2**k + 1 - 1:
    print(-1)
else:
    tree = [0] * (2 * n)
    for i in range(n):
        tree[n + i] = a[i]

    for i in range(n - 1, 0, -1):
        tree[i] = min(tree[2 * i], tree[2 * i + 1])

    if tree[1] == min(a):
        print(*a)
    else:
        print(-1)
