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

b = list(set(sorted(a)))
m = b[-1]
if len(b) == 1:
    m1 = b[-1]
else:
    m1 = b[-2]

for idx,i in enumerate(a):
    if m != i:
        print(m)
    else:
        print(m1)