import copy
N = int(input())

A = [0]*N

for r in range(N):
  A[r] = int(input())
Elias_A = copy.copy(A)
A.sort()
Sorted_A = copy.copy(A)
  
for r in range(N):
  A.remove(Elias_A[r])
  print(A[N-2])
  A = copy.copy(Sorted_A)