# -*- coding: utf-8 -*-
N = int(input())
A = [int(input()) for i in range(N)]
temp = 0

for i in range(N):
	if A[i] != max(A):
		print(max(A))
	else:
		temp = A[i]
		del A[i]
		print(max(A))
		A.insert(i,temp)
		temp = 0