loop do
  n = gets.to_i
  break if n == 0
  ary = []
  sum = 0
  0.upto(n-1) do |i|
    ary[i] = gets.to_i
  end
  ary.delete_at(ary.find_index(ary.max))
  ary.delete_at(ary.find_index(ary.min))
  ary.each do |x|
    sum += x
  end
  puts sum / ary.size
end