N = gets.to_i
Ary = gets.split.map(&:to_i).sort

count = 0
Ary.each.with_index do |a, i|
  break if i == Ary.size - 1
  Ary[(i+1)..-1].each.with_index do |b, j|
    # binding.irb
    last_index = (Ary[(i+j+2)..-1].count { |c| a + b > c } )
    if last_index
      count += last_index
    end
  end
end

puts count
