f = Array.new(2){ Array.new(4001, 0) }
f[0][0] = 1
4.times do |j|
  f[1].fill(0)
  (0..1000*j).each do |i|
    (0..1000).each do |k|
      f[1][i+k] += f[0][i]
    end
  end
  f.rotate!
end 
while n = gets.to_i
  p f[0][n]
end