N = int(input())
A = [int(input()) for _ in range(N)]

if len(set(A)) == 1:
  for _ in range(N):
    print(max(A))
else:
  for i in range(N):
    if A[i] == max(A):
      print(sorted(set(A))[-2])
    else:
      print(max(A))