n = gets.to_i
l = gets.chomp.split.map(&:to_i).sort_by{|x| x}

count = 0
(n-1).times do |i|
  (i+1..n-1).each do |j|
    a = l[i]
    b = l[j]
    (j+1..n-1).each do |k|
      c = l[k]
      if l[k] < a+b
        if a-b<c && b-a<c
          count += 1
        end
      else
        break
      end
    end
  end
end

print count