N = int(input())

A_i = []
for i in range(N):
    A_i.append(int(input()))

A_i_max = max(A_i)

for i in range(N):
    if A_i_max == A_i[i] and A_i.count(A_i[i]) == 1:
        A_i_copy = A_i[:]
        A_i_copy.pop(i)
        print(max(A_i_copy))
    else:
        print(A_i_max)