n = int(input())
num = [ int(input()) for _ in range(n) ]
B = sorted(num,revese=True)
maxnum = B[0]
maxnum2 = B[1]

for i in range(n):
    if num[i] != maxnum:
        print(maxnum)
    else:
        print(maxnum2)