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

ls = ls.sort

ret = 0

i = 0
while i < N
  j = i + 1
  prev = nil
  while j < N
    if prev
      k = prev
      ret += prev-(j+1)
    else
      k = j + 1
    end
    while k < N
      if ls[i] + ls[j] <= ls[k]
        prev = k
        break
      else
        ret += 1
      end
      k += 1
    end
    j += 1
  end
  i += 1
end

p ret

