n = int(input())
a = [int(input()) for _ in range(n)]
max_a = max(a)
set_a = sorted(set(a))
for i in range(n):
    if max_a == a[i]:
        if len(set(a)) == 1:
            print(max_a)
        else:
            print(set_a[-2])
    else:
        print(max_a)