import numpy as np

N = int(input())

A = np.array([])

for i in range(N):
	a = int(input())
	A = np.hstack( (A,a) )

for i in range(N):
	B = A
	#print(np.argmax(A))
	if i == (np.argmax(A)):
		B = np.delete(B, i)
		ans = np.amax(B)
	else:
		ans = np.amax(A)
	print(int(ans))
