N = int(input())
A = [int(input()) for i in range(N)]
maxnum = max(A)
for i in range(N):
    if i == maxindex:
        tmp = A
        del tmp[tmp.index(max(tmp))]
        print(max(tmp))
    else:
        print(maxnum)