let a = Array.init 4001 (fun x -> 0);;
let () =
  let rec loop b = function
      2001 -> ()
    | i ->
       let t = (i+3)*(i+2)*(i+1)/6 and
           v = if i > 1000 then b + (i-999)*(i-1000)/2 else b in
       a.(i) <- t-v;
       a.(4000-i) <- a.(i);
       loop v (i+1)
  in loop 0 0;;

let rec read () =
  try let n = read_int () in
      Printf.printf "%d\n" a.(n);read ()
  with End_of_file -> ()
;;

let () = read ();;