N=int(input())
A=[]
for _ in range(N):
  A.append(int(input()))

index = A.index(max(A))
for i in range(N):
  if i==index:
    b=A.pop(i)
    print(max(A))
    A.insert(i,b)
  else:
      print(max(A))