n = int(input())
A = [int(input()) for i in range(n)]
m = max(A)

for i in range(n):
    if i == A.index(max(A)):
        ans = A[:]
        ans.pop(i)
        print(max(ans))
    else:
        print(m)
