N = int(input())
A=[]
for i in range(N):
  temp = int(input())
  A.append(temp)

B = A.copy()
for j in range(N):
  if max(A) == A[j]:
    del A[j]
    print(max(A))
    A = B.copy()
  else:
    print(max(A))
 
