n = int(input())
a = [int(input()) for i in range(n)]
x = a.count(max(a))
if 2 <= x:
    for i in range(n):
        print(max(a))
else:
    for i in range(n):
        if a[i] == max(a):
            print(max(a[:i] + a[i+1:]))
        else:
            print(max(a))