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|
    (b+1...n).each do |c|
      if l[a] + l[b] > l[c]
        count += 1
      else
        break
      end
    end
  end
end
  
puts count