#include <iostream>
#include <cstring>

int half[2001]; //0<=a, b<=1000 として a+b となる組み合わせの数

void makeSet(){
	memset(half, 0, sizeof(half));
	//半分全列挙
	for(int i=0; i<=1000; ++i){
		for(int j=0; j<=1000; ++j){
			int k=i+j;
			++half[k];
		}
	}
}

int solve(int n){
	int num=0;
	int max=n<2000?n:2000; //Counterが半分全列挙の上限を超えない為

	for(int i=0; i<=max; ++i){
		if(n-i<=2000) num+=half[i]*half[n-i]; //左半分の組み合わせ * 右半分の組み合わせ = 全組み合わせ
	}
	return num;
}

int main(){
	makeSet();

	while(true){
		int n;
		std::cin>>n;
		if(std::cin.eof()) break;
		
		std::cout<<solve(n)<<std::endl;
	}
	return 0;
}
### Prompt

Create a solution in Cpp for the following problem:

Enter a positive integer n of 4,000 or less, with a pair of integers a, b, c, d in the range 0-1000.


a + b + c + d = n


Create a program that outputs the number of combinations that satisfy the conditions.



Input

Given multiple datasets. Each dataset is given n on one row. Please process until the end of the input.

The number of datasets does not exceed 50.

Output

For each data set, output the number of combinations of a, b, c, and d on one line.

Example

Input

2
3
35


Output

10
20
8436

### Response

```cpp
#include <iostream>
#include <cstring>

int half[2001]; //0<=a, b<=1000 として a+b となる組み合わせの数

void makeSet(){
	memset(half, 0, sizeof(half));
	//半分全列挙
	for(int i=0; i<=1000; ++i){
		for(int j=0; j<=1000; ++j){
			int k=i+j;
			++half[k];
		}
	}
}

int solve(int n){
	int num=0;
	int max=n<2000?n:2000; //Counterが半分全列挙の上限を超えない為

	for(int i=0; i<=max; ++i){
		if(n-i<=2000) num+=half[i]*half[n-i]; //左半分の組み合わせ * 右半分の組み合わせ = 全組み合わせ
	}
	return num;
}

int main(){
	makeSet();

	while(true){
		int n;
		std::cin>>n;
		if(std::cin.eof()) break;
		
		std::cout<<solve(n)<<std::endl;
	}
	return 0;
}
```