_n = gets.to_i
nums = gets.strip.split.map(&:to_i).sort
ans = 0
while nums.size > 2
  l1 = nums.shift
  (nums.size-1).times do |m|
    l2 = nums[m]
    m += 1
    while nums[m] && (nums[m] - l2 < l1)
      ans += 1
      m += 1
    end
  end
end
puts ans