loop do
  n = gets.chomp.to_i
  break if n == 0

  total = 0
  max = 0
  min = 1000
  n.times do |i|
    score = gets.chomp.to_i
    max = max < score ? score : max
    min = min > score ? score : min
    total += score
  end

  puts (total - (max + min)) / (n - 2)
end