N = gets.to_i
array=gets.chomp.split(" ").map(&:to_i).sort

ret = 0 
(0..(N-3)).each do |i|
    x = array[i]
    ((i+1)..(N-2)).each do |j|
        y = array[j]
        ((j+1)..(N-1)).each do |k|
            z = array[k]
            if z < x + y
                ret += 1
            else
                break
            end
        end
    end
end
puts ret