N=int(input())
A=[]

for i in range(N):
  A.append(int(input()))

for j in range(N):
  if j == A.index(max(A)) and A.count(max(A)) == 1:
    B=[i for i in A if i != max(A)]
    print(max(B))
  else:
    print(max(A))