n = gets.to_i
l = gets.split.map(&:to_i).sort
count = 0
for i in 0..(n-3) do
  a = l[i]
  for j in (i+1)..(n-2) do
    b = l[j]
    for k in (j+1)..(n-1) do
      c = l[k]
      if c < a + b
        count += 1
      else
        break
      end
    end
  end
end
puts count
