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

a = max(A)
A_max = []
for i in range(N):
  if A[i] != a:
    A_max.append(a)
  else:
    A_ = A[:]
    A_[i] = 0
    A_max.append(max(A_))
    
for i in A_max:
  print(i)