N = int(input())
A = [int(input()) for _ in range(N)]

count = 0
for i in range(N):
    if A[i] == max(A):
        count += 1

for i in range(N):
    if A[i] == max(A) and count>1:
        print(max(A))
    elif A[i] == max(A) and count==1:
        tmp = A[i]
        A[i]=0
        print(max(A))
        A[i]=tmp
    else:
        print(max(A))