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

for i in range(N):
  if len(a) > 1:
    if A[i] != a[-1]:
      print(a[-1])
    else:
      print(a[-2])
  else:
    print(a[-1])