num=Array.new(4000,0)
1001.times{|a|1001.times{|b|num[a+b]+=1}}
while gets
    n=$_.to_i
    count=0
    2001.times do|x|
        if n-x>=0
            count+=num[x]*num[n-x]
        else
            break
        end
    end
    p count
end