N = gets.to_i
ls = gets.split.map(&:to_i)

ls = ls.sort

ret = 0

i = 0
while i < N
  j = i + 1
  k = j + 1
  while k < N
    if ls[i] + ls[j] <= ls[k]
      j += 1
      if j == k
        k += 1
      end
    else
      ret += k - j
      k += 1
    end
  end
  i += 1
end

p ret

