n = int(input())
a = []
for _ in range(0, n):
    a.append(int(input()))
for i in range(0, n):
    if not a[i] == max(a):
        print(max(a))
    else:
        b = a.pop(i)
        print(max(a))
        a.insert(i, b)
        