n = int(input())
a = list()
for x in range(n):
    a.append(int(input()))

copy_a = sorted(a, reverse=True)

A_Max = a[0]
A_Second = a[1]

for x in range(n):
    if copy_a[x] == A_Max:
        print(A_Second)
    else:
        print(A_Max)
