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

d = {i: v for i, v in enumerate(a)}
d = dict(sorted(d.items(), key=lambda x:x[1],reverse=True))
#print(d)
#print("===")
for i in range(n):
    if i == list(d.keys())[0]:
        print(list(d.values())[1])
    else:
        print(list(d.values())[0])