io = STDIN
n=io.gets.to_i
l=io.gets.split.map(&:to_i).sort
cnt=0
l[0..-3].each_with_index do |a,i|
   l[i+1..-2].each_with_index do |b,j|
      k=l[i+j+2..-1].bsearch_index{|c|c>b-a}
      break unless k
      km=l[k+i+j+2..-1].bsearch_index{|c|c>=b+a}
      if km
        cnt+=km #if a<b+c
      else
        cnt+=n-1-(i+j+1)
      end
   end
end
p cnt
