f1 = ->(n) {(n ** 3 + 6 * n ** 2 + 11 * n + 6) / 6}
f2 = ->(n) {
  n1 = n - 1000
  (335337002 + 1004001 * n1 + 998 * n1 ** 2 - n1 ** 3) / 2
}
f3 = ->(n) {
  n1 = n - 2001
  (1337336000 - 4002 * n1 - 1999 * n1 ** 2 + n1 ** 3) / 2
}
f4 = ->(n) {
  n1 = n - 3002
  (999999000 - 2999999 * n1 + 3000 * n1 ** 2 - n1 ** 3) / 6
}

$<.readlines.map(&:to_i).each do |s|
  result = case s
           when    0..1000 then f1.(s)
           when 1001..2001 then f2.(s)
           when 2002..3002 then f3.(s)
           when 3003..4000 then f4.(s)
           end
  puts result
end
