import sys
n = int(sys.stdin.readline())
A = [int(sys.stdin.readline()) for _ in range(n)]
tmp = sorted(A)
for i in range(n):
    if A[i] == max(A):
        print(tmp[-2])
    else:
        print(max(A))