n = gets.to_i
l = gets.chomp.split.map(&:to_i).sort!
sl = l.reverse
res = 0
2.step(n - 1) do |k|
  1.step(k - 1) do |j|
    b, c = l[j], l[k]
    lb = l[0...j].bsearch_index {|a| a > c - b } || j
    ub = l[0...j].bsearch_index {|a| a > b + c } || j
    res += ub - lb
  end
end
puts res
