N = int(input())
A = [int(input()) for i in range(N)]
B = list(set(A))
B.sort()
B.reverse()
if len(B) == 1:
  for i in range(N):
    print(B[0])
else:
  for i in range(N):
    if A[i] == B[0]:
      print(B[1])
    else:
      print(B[0])