N = int(input())
list = [int(input()) for i in range(N)]
a = max(list)
for i in range(N):
    if list[i] == a:
        b = list[i]
        list[i] = 0
        print(max(list))
        list[i] = b
    else:
        print(a)
