-- prev 0.6sec total

import Data.Array

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

cases2 n
    | 2000<n    = 0
    | n<=1000   = n+1
    | otherwise = (mymax 1000 (n-1000))-(mymin 1000 (n-1000))+1

acases2 :: Array Int Int
acases2 = array (0,2000) $ map (\i->(i,cases2 i)) [0..2000]

cases3 n
    | 3000<n    = 0
    | otherwise = sum $ map (\x->acases2!(n-x)) [(mymax 0 (n-2000))..(mymin n 1000)]

cases4 n = sum $ map (\x->cases3 (n-x)) [(mymax 0 (n-3000))..(mymin n 1000)]

solve n = do
    print $ cases4 n

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