n = int(input())
a = [int(input()) for i in range(n)]

m = max(a)

for i in range(n):
    if m > a[i]:
        print(m)
    else:
        b = a[i]
        a.remove(b)
        print(max(a))
        a.insert(i,b)
