N = gets.to_i
L = gets.chomp.split(" ").map(&:to_i)

L.sort!
ans = (0..(N - 2)).to_a.combination(2).inject(0){|r, (a, b)|
  idx = L.bsearch_index{|c| c >= L[a] + L[b]}
  idx = N if idx.nil?
  r + idx - b - 1
}

puts ans
