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

# 
original_array = [0] * n

# 
def build_segment_tree(node, left, right):
    if left == right:
        segment_tree[node] = original_array[left]
        return
    mid = (left + right) // 2
    build_segment_tree(2 * node, left, mid)
    build_segment_tree(2 * node + 1, mid + 1, right)
    segment_tree[node] = min(segment_tree[2 * node], segment_tree[2 * node + 1])

# 
def restore_array(node, left, right):
    if left == right:
        original_array[left] = segment_tree[node]
        return
    mid = (left + right) // 2
    left_min = segment_tree[2 * node]
    right_min = segment_tree[2 * node + 1]
    if left_min <= right_min:
        restore_array(2 * node, left, mid)
    else:
        restore_array(2 * node + 1, mid + 1, right)

# 
distinct_values = set(values)
if len(distinct_values) != n:
    print(-1)
else:
    # 
    original_array = [0] * n
    segment_tree = [0] * (4 * n)
    build_segment_tree(1, 0, n - 1)
    restore_array(1, 0, n - 1)
    if original_array == values:
        print(" ".join(map(str, original_array)))
    else:
        print(-1)
