while true
  judge_size = gets.to_i
  break false if judge_size == 0
  numbers = []
  judge_size.times do |_|
    numbers << gets.to_i
  end
  sum = numbers.inject(0){|a,x| a + x }
  puts (sum - numbers.max - numbers.min) / (judge_size - 2)
end