n = int(input())
a = [int(input()) for _ in range(n)]
max_list = max(a)
for i in range(n):
    if a[i] == max_list:
        ans = sorted(list(a))[-2]
        print(ans)
    else :
        print(max_list)