
mymin x y = if x>y then y else x
mymax x y = if x>y then x else y

cases n 2
    | 2000<n    = 0
    | n<=1000   = n+1
    | otherwise = (mymax 1000 (n-1000))-(mymin 1000 (n-1000))+1
cases n num 
    | 1000*num<n = 0
    | otherwise  = sum $ map (\x->cases (n-x) (num-1)) [0..(mymin n 1000)]

solve n = do
    print $ cases n 4

main = do
    ss<-getContents
    mapM_ solve $ map (\x->read x::Int) $ lines ss