N = int(input())
A = [0] * N
for i in range(N):
    A[i] = int(input())

set_A = set(A)
count_A = A.count(max(A))
for a in A:
    if a == max(A) and count_A == 1:
        print(sorted(set(set_A))[-2])
    else:
        print(max(A))