N = int(input())
A = [0 * x for x in range(N)]
B = [0 * x for x in range(N-1)]

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

for i in range(N):
  M = max(A)
  if A[i] == M:
    M = max(A[:i]+A[i+1:])
  print (M)
