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("===")
k_t = list(d.keys())[0]
v_t = list(d.values())[0]
v_s = list(d.values())[1]
for i in range(n):
    if i == k_t:
        print(v_s)
    else:
        print(v_t)