n = gets.to_i
l=gets.split(" ").map(&:to_i)
l.sort!
count =0


for i in 0..n-3

  for m in i+1..n-2
    t=m+1

    while t<n && l[i]+l[m]>l[t]
      t+=1

    end
    count+= t-1-m
  end
end

puts count

