import sys
import heapq
import copy

n = int(input())
a = []

for _ in range(n):
	a.append(-1 * int(input()))

for i in range(n):
	b = copy.deepcopy(a)
	heapq.heapify(b)
	maximum = heapq.heappop(b)
	if maximum == a[i]:
		print(heapq.heappop(b) * (-1))
	else:
		print(maximum * (-1))
