n = gets.to_i
arr = gets.chomp.split(' ').map(&:to_i).sort
i = 0
count = 0
while i < n
  j = i + 1
  while j < n
    k = j + 1
    while k < n
      if arr[i] + arr[j] > arr[k]
        count += 1
      else
        break
      end
      k += 1
    end
    j += 1
  end
  i += 1
end
puts count