n = int(input())
a = [int(input()) for i in range(n)]
a_s = sorted(a, reverse=True)
a_max_ind = index(max(a))
a_max = a_s[0]
a_sec = a_s[1]
for i in range(n)
    if i == a_max_ind:
        print(a_sec)
    else:
        print(a_max)