N = int(input())
A = [int(input()) for i in range(N)]
maxa = max(A)
for i in range(N):
    if maxa == A[i]:
        tmp = A.pop(i)
        print(max(A))
        A.insert(i,tmp)
    else:
        print(maxa)