n = gets.to_i
l = gets.split.map(&:to_i)
l.sort!
lp = l.reverse
ans = 0
(0..n-2).each do |i|
  (i+1..n-2).each do |j|
    #p [i,j,r,q]
    if ((n-1) - lp.index{|x| x < l[i]+l[j]}) != nil && (l.index{|x| x > l[j]-l[i]}) != nil
      ans += ((n-1) - lp.index{|x| x < l[i]+l[j]})-[l.index{|x| x > l[j]-l[i]},j+1].max + 1 unless ((n-1) - lp.index{|x| x < l[i]+l[j]})-[l.index{|x| x > l[j]-l[i]},j+1].max + 1 <= 0
    end
  end
end
puts ans