# n = 3
n = int(input())

lg, slg = 0, 0

arr = [0]*n

for i in range(n):
	arr[i] = int(input())
	if i==0:
		lg = i 
	elif arr[i] >= arr[lg]:
		slg = lg
		lg = i
	elif arr[i] >= arr[slg]:
		slg = i 


for i in range(n):
	if i==lg:
		print(arr[slg])
	else:
		print(arr[lg])