n = int(input())
a = []
b = []

for i in range(n):
    t = int(input())
    a.append(t)
    b.append(t)

for i in range(n):
    b.sort()
    b.remove(a[i])
    print(b[-1])
    b.append(a[i])
    b.sort()
