io = STDIN
n=io.gets.to_i
l=io.gets.split.map(&:to_i).sort
cnt=0
#a+b>c
#b+c>a  c>a-b
#c+a>b  c>b-a
(0...n-2).each do |i|
   (i+1...n-1).each do |j|
      apb=l[i]+l[j]
      k=l[j+1,n-j-1].bsearch_index{|c|c>=apb}
      cnt+=k||n-1-j
   end
end
p cnt
