n = gets.chomp.to_i
ary1 = gets.chomp.split(" ").map(&:to_i)
ary1.sort!
count = 0
cmax = ary1[n-1]
#p cmax
p ary1
(n-3).times do |i|
  (n-2-i).times do |j|
    a = ary1[i]
    b = ary1[j+1+i]
    if a+b <= ary1[j+1+i+1]
    else
      ary_c = ary1[(i+j+2..n-1)]
      search_result = ary_c.bsearch_index{|c|  c >= a+b }
      if search_result
        count += search_result
        p count
      else
        count += ary_c.length
        p count
      end
      # count = ary1.bsearch_index{|c|  c < a+b } -(j+1+i)
    end
  end  
end

puts count