a = []
n = int(input())
for i in range(n) :
	x = int(input())
	a.append(x);
	pass
for i in range(n) :
	if i == 0:
		print(max(a[1:n]))
	elif i == n - 1:
		print(max(a[0:n - 1]))
	else :
		print(max(a[0:i], a[i+1:n]))
