N = gets.to_i
ls = gets.split(' ').map(&:to_i).sort.reverse!
count = 0
(0..(N - 3)).each do |a|
  ((a + 1)..(N - 2)).each do |b|
    i = ls.slice((b + 1)..N).bsearch_index { |c| c <= ls[a] - ls[b] } || N - (b + 1)
    count += i
  end
end
p count