n = gets.to_i
l = gets.split.map(&:to_i).sort
count = 0
(0...n-2).each do |a|
  (a+1...n-1).each do |b|
    t = l[a] + l[b]
    pos = l[b+1..-1].bsearch_index {|x| x >= t}
    count += pos ? pos : n-b-1
  end
end
  
puts count