n = int(input())
ls = []
for i in range(n):
    ls.append(int(input()))
maxnum = max(ls)
for i in range(n):
    if maxnum > ls[i]:
        print(maxnum)
    else:
        lstmp = ls[0:i] + ls[i+1:]
        print(max(lstmp))
