while (line = gets.chomp.to_i) != 0 

    n = line
    
    score = []
    
    n.times{
        score << gets.chomp.to_i   
    }
    
    puts (score.inject(:+) - score.max - score.min)/(n-2)
    
end 