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())

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