n=int(input())
A=[int(input()) for i in range(n)]
if n==2:
  print(A[1])
  print(A[0])
  exit()

for i in range(n):
  if i==0:
    q=max(A[1:])
    print(q)
    continue
  if A[i]!=q:
    print(q)
  else:
    print(max(A[:i]+A[i+1:]))
