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

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