N = gets.to_i
Ls = gets.split.map(&:to_i)

ls = Ls.sort
ans = 0
(2 ... N).each do |a|
  b = a - 1
  c = 0
  while c < b
    if ls[a] >= ls[b] + ls[c]
      c += 1
    else
      ans += b - c
      b -= 1
    end
  end
end
puts ans