while true
  judges = gets.to_i
  break if judges == 0
  a = Array.new(judges)
  for i in 0..(judges-1)
    a[i] = gets.to_i
  end
  sum = 0
  for i in 0..(judges-1)
    sum = sum + a[i]
  end
  sum = sum - a.max - a.min
  puts sum/(judges-2)
end