n = int(input())
a = list()
b = list()
for i in range(n):
    x = input()
    a.append(int(x))
b = sorted(a)
for i in range(n):
    if b[-1] == a[i] and a.count(b[-1]):
        print(b[-2])
    else:
        print(b[-1])