import copy
N=int(input())
A=[]
for i in range(N):
  A.append(int(input()))

x=max(A)
for i in range(N):
    if A[i]==x:
        B=copy.copy(A)
        B.pop(i)
        print(max(B))
    else:
        print(x)