import heapq
N = int(input())
A = []
for _ in range(N):
    A.append((-1) * int(input()))

for i in range(N):
    list = A[:i] + A[i + 1:]
    heapq.heapify(list)
    print((-1) * heapq.heappop(list))