while (n = gets.chomp.to_i) != 0
  sum = 0
  max = -1
  min = 1001

  n.times do
    s = gets.chomp.to_i
    sum += s
    
    if s > max
      max = s
    end
    if s < min
      min = s
    end
  end

  sum -= (min + max)
  puts sum/(n-2)
end