N=int(input())
A=[]
for i in range(N):
    a=int(input())
    A.append(a)
for j in range(N):
    if A[j]==max(A):
        b=A[j]
        del A[j]
        print(max(A))
        A.insert(j, b)
    else:
        print(max(A))
