data = []

def maxsearchex(n):
	maxInt = 0
	for i in range(len(data)):
		if i != n:
			if maxInt < data[i]:
				maxInt = data[i]
	print(maxInt)

i = input()

for n in range(int(i)):
	data.append(int(input()))

for i in range(len(data)):
	maxsearchex(i)

