function getlines(n)
	an = []
	for i in 1:n	
		elem = readline()
		elem = parse(Int, elem)
		push!(an, elem)
	end
    return an
end 
function answer(n, an)
	for i in 1:n
		an_tmp = copy(an)
		deleteat!(an_tmp, i)
		res, ind = findmax(an_tmp)
		print(res)
        if i != n
			print("\n")
		end
	end
end
n = readline()
n = parse(Int, n)
an = getlines(n)
answer(n, an)