loop do
  n = gets.chomp.to_i
  break if n == 0
  scores = []
  n.times do |i|
    scores << gets.chomp.to_i
  end

  total = scores.inject{|memo, item| memo + item}
  total -= (scores.max + scores.min)
  puts total / (n - 2)
end