result = []
while true do
	n = gets.chomp.to_i
	if n == 0 then break end
	ary = []

	n.times{
		ary << gets.chomp.to_i
	}

	ary_min=ary.min
	ary_max=ary.max

	ary.each_with_index{|val, index| if val == ary_min then 
		ary.delete_at(index)
	    break
	    end}

	ary.each_with_index{|val, index| if val == ary_max then 
		ary.delete_at(index)
	    break
	    end}

	sum = 0
	ary.each{|val| sum += val}

	result << sum/ary.length 
end

result.each{|val| puts val}