import numpy as np
import heapq
N = int(input())
A = []
for _ in range(N):
  A.append(-1*int(input()))
A = np.array(A)
answer = []
for i in range(N):
  A_temp = np.delete(A, i).tolist()
  heapq.heapify(A_temp)
  answer.append(heapq.heappop(A_temp))
for i in range(N):
  print(-1*answer[i])