N = int(input())
A = list()
for i in range(N):
  A.append(int(input()))
ma = max(A)
for i in range(N):
  if ma != A[i]:
    print(ma)
  else:
    X = A[i]
    A[i] = 0
    print(max(A))
    A[i] = X

  