def resolve():
    n = int(input())
    aaa = [int(input()) for _ in range(n)]
    maxa = max(aaa)
    for i in range(n):
        if maxa == aaa[i]:
            print(max(aaa[:i]+aaa[i+1:]))
        else:
            print(maxa)
resolve()