N = gets.chomp.to_i
L = gets.chomp.split.map(&:to_i)
L.sort!

cnt=0
(0..(N-2)).each do |i|
  ((i+1)..(N-1)).each do |j|
    idx = L[(j+1)..-1].index{|length| length >= L[i] + L[j]}
    if idx.nil?
      cnt += (N - 1) - j
    else
      cnt += idx
    end
  end
end

puts cnt