import copy
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
for j in range(N):
    if (A[j] != max(A)):
        print(max(A))
    else:
        J = copy.deepcopy(A)
        del J[j]
        print(max(J))