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
	ans = np.amax(A)
	j = np.argmax(A)
	ans2 = np.amax(np.delete(A,j))
	if i == j:
		ans = ans2
	print(int(ans))
