N = int(input())
from collections import Counter
A = []
for i in range(N):
  A.append(int(input()))

sorted_A = sorted(A, reverse=True)  
for a in A:
  tmp_A = list(sorted_A)
  tmp_A.remove(a)
  print(tmp_A[0])