import math

def reconstruct_array(n, values):
    k = int(math.log2(n + 1) - 1)
    original_array = [0] * n

    def fill_array(root_index, start, end):
        if start == end:
            original_array[start] = values[root_index]
            return
        mid = (start + end) // 2
        fill_array(2 * root_index + 1, start, mid)
        fill_array(2 * root_index + 2, mid + 1, end)
        original_array[mid] = min(original_array[2 * root_index + 1], original_array[2 * root_index + 2])

    fill_array(0, 0, n - 1)
    return original_array

n = int(input())
values = list(map(int, input().split()))
result = reconstruct_array(n, values)
print(*result)
