N = gets.to_i
L = gets.split.map(&:to_i)
L.sort!
# p L
ans = 0
 
0.upto(N - 3) do |i|
  (i + 1).upto(N - 2) do |j|
    pos = L[j+1..-1].bsearch_index { |l| l >= L[i] + L[j] }
    pos = L.size - (j + 1) if pos.nil?
    # p [L[i], L[j], i, j, min_len, pos, j - pos]
    ans += pos
  end
end

puts ans
