while true do
  n = gets.to_i
  if n == 0
    break
  end
  max = 0
  min = 10000
  sum = 0
  n.times do
    i = gets.to_i
    if i > max
      max = i
    elsif i < min
      min = i
    end
    sum += i
  end
  p (sum - min - max) / (n-2)
end