import heapq
import copy
N = input()
A = [-int(input()) for _ in range(int(N))]
for idx, a in enumerate(A):
    A_heap = copy.deepcopy(A)
    A_heap.pop(idx)
    heapq.heapify(A_heap)
    pop_A = heapq.heappop(A_heap)
    print(-(pop_A))