while true
    judges = gets.to_i
    break if judges == 0
    b = []
    for i in 0..judges-1
        b << gets.to_i
    end
    b.delete_at(b.index(b.max))
    b.delete_at(b.index(b.min))
    sum = 0
    for i in 0..judges-3
        sum = sum + b[i]
    end
    puts sum / (judges-2)
end