n = int(input())
A = [int(input()) for _ in range(n)]
B = A[:]
max_A = max(A)
for i in range(n):
    if A[i] == max_A:
        B[i] = 0
        print(max(B))
        B[i] = max_A
    else:
        print(max_A)