N,*ls=$<.read.split.map(&:to_i)

ls = ls.sort + [9999]

ret = 0

0.upto(N-3) do |i|
  j = i+1
  k = j+1
  while k <= N
    if ls[i]+ls[j] <= ls[k]
      ret += k-j-1
      j += 1
    else
      k += 1
    end

    if j == k
      k = j+1
    end
  end
end

p ret
