f :: Int -> Int
f n
  |n > 1000 = 2001 - n
  |otherwise = n + 1

getRange :: Int -> [Int]
getRange n
  |n > 2000 = [(n - 2000)..2000]
  |otherwise = [0..n]

solve :: Int -> Int
solve n = sum [(f x) * (f (n - x)) | x <- getRange n]

main = do
  input <- getContents
  mapM_ print $ map solve (map (\n -> read n :: Int) (lines input))