while true do
  person_count = gets.to_i
  break if person_count == 0

  scores = person_count.times.map {gets.to_i}
  p (scores.reduce {|sum, n| sum + n} - scores.max - scores.min) / (person_count - 2)

end