# frozen_string_literal: true

n = gets.to_i
l = gets.split.map(&:to_i).sort
count = 0
0.upto(n - 3) do |i|
  a = l[i]
  (i + 1).upto(n - 2) do |j|
    b = l[j]
    c_lower = j + 1
    add = 0
    c_upper = l.bsearch_index { |e| a + b <= e }
    if c_upper.nil?
      c_upper = n - 1
      add = 1
    end
    next if c_upper < c_lower

    diff = c_upper - c_lower
    diff = 0 if diff.negative?

    count += diff + add
  end
end

puts count
