N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

max_A = max(A)
sorted_A = list(sorted(list(set(A))))
for i in range(N):
    if A[i] == max_A:
        print(sorted_A[len(sorted_A)-2])
    else:
        print(max_A)
