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

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

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