n = int(input())
a = list(int(input()) for _ in range(n))

num = max(a)
try:
    num2 = max([k for k in a if k != num])
except:
    pass
for i in range(n):
    if a[i] < num:
        print(num)
    else:
        print(num2)