n = gets.chomp.to_i
lines = gets.chomp.split(' ').map(&:to_i).sort.reverse
num = 0

(n-2).times do |i|
  j = i + 1
  k = n - 1
  while j < k do
    if lines[i] < lines[j] + lines[k]
      num += k - j
      j += 1
    else
      k -= 1
    end
  end
end

print(num)
