N=int(input())
A=[int(input()) for n in range(N)]
#print(max(A[1:]))
#for i in range(1,N-1):
m=max(A)
for i in range(N):
	if A[i]<m:
    	print(m)
	else:
    	print(max(A[:i]+A[i+1:]))
#print(max(A[:N-1]))
