def second(s):
    s.sort()
    s.reverse()
    return s[1]

N = int(input())
A = [int(input()) for i in range(N)]
for i in range(0,N):
    if A[i]==max(A):
        ans=second(A)
        print(ans)
    else:
        print(max(A))
    