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

TempMax=max(A)
for j in range(N):
    if A[j] == Tempmax:
        B = copy.copy(A)
        print(max(B.pop(j))
    else: print(TempMax)