#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int f[4001];

void cheat();

int main(){
	fill(f, f + 4001, -1);
	cheat();
	int n;
	while( cin >> n ){
		if( f[n] != -1 ){
			cout << f[n] << endl;
			continue;
		}
		
		vector<int> v;
		for(int i = 0; i <= 1000; i++){
			if( n < i ) break;
			for(int j = 0; j <= 1000; j++){
				if( n < i + j ) break;
				if( n <= i + j + 2000 ) v.push_back(i + j);
			}
		}
		sort(v.begin(), v.end());
		int ans = 0;
		for(int i = 0; i < v.size(); i++){
			int k = n - v[i];
			int res = upper_bound(v.begin(), v.end(), k) - lower_bound(v.begin(), v.end(), k);
			ans += res;
		}
		f[n] = f[4000 - n] = ans;
		cout << f[n] << endl;
	}
}

void cheat(){
f[1000] = 167668501;
f[1020] = 177904111;
f[1040] = 188514921;
f[1060] = 199476931;
f[1080] = 210766141;
f[1100] = 222358551;
f[1120] = 234230161;
f[1140] = 246356971;
f[1160] = 258714981;
f[1180] = 271280191;
f[1200] = 284028601;
f[1220] = 296936211;
f[1240] = 309979021;
f[1260] = 323133031;
f[1280] = 336374241;
f[1300] = 349678651;
f[1320] = 363022261;
f[1340] = 376381071;
f[1360] = 389731081;
f[1380] = 403048291;
f[1400] = 416308701;
f[1420] = 429488311;
f[1440] = 442563121;
f[1460] = 455509131;
f[1480] = 468302341;
f[1500] = 480918751;
f[1520] = 493334361;
f[1540] = 505525171;
f[1560] = 517467181;
f[1580] = 529136391;
f[1600] = 540508801;
f[1620] = 551560411;
f[1640] = 562267221;
f[1660] = 572605231;
f[1680] = 582550441;
f[1700] = 592078851;
f[1720] = 601166461;
f[1740] = 609789271;
f[1760] = 617923281;
f[1780] = 625544491;
f[1800] = 632628901;
f[1820] = 639152511;
f[1840] = 645091321;
f[1860] = 650421331;
f[1880] = 655118541;
f[1900] = 659158951;
f[1920] = 662518561;
f[1940] = 665173371;
f[1960] = 667099381;
f[1980] = 668272591;
f[2000] = 668669001;
f[2020] = 668272591;
f[2040] = 667099381;
f[2060] = 665173371;
f[2080] = 662518561;
f[2100] = 659158951;
f[2120] = 655118541;
f[2140] = 650421331;
f[2160] = 645091321;
f[2180] = 639152511;
f[2200] = 632628901;
f[2220] = 625544491;
f[2240] = 617923281;
f[2260] = 609789271;
f[2280] = 601166461;
f[2300] = 592078851;
f[2320] = 582550441;
f[2340] = 572605231;
f[2360] = 562267221;
f[2380] = 551560411;
f[2400] = 540508801;
f[2420] = 529136391;
f[2440] = 517467181;
f[2460] = 505525171;
f[2480] = 493334361;
f[2500] = 480918751;
f[2520] = 468302341;
f[2540] = 455509131;
f[2560] = 442563121;
f[2580] = 429488311;
f[2600] = 416308701;
f[2620] = 403048291;
f[2640] = 389731081;
f[2660] = 376381071;
f[2680] = 363022261;
f[2700] = 349678651;
f[2720] = 336374241;
f[2740] = 323133031;
f[2760] = 309979021;
f[2780] = 296936211;
f[2800] = 284028601;
f[2820] = 271280191;
f[2840] = 258714981;
f[2860] = 246356971;
f[2880] = 234230161;
f[2900] = 222358551;
f[2920] = 210766141;
f[2940] = 199476931;
f[2960] = 188514921;
f[2980] = 177904111;
f[3000] = 167668501;
f[3020] = 157827531;
f[3040] = 148379361;
f[3060] = 139315991;
f[3080] = 130629421;
f[3100] = 122311651;
f[3120] = 114354681;
f[3140] = 106750511;
f[3160] = 99491141;
f[3180] = 92568571;
f[3200] = 85974801;
f[3220] = 79701831;
f[3240] = 73741661;
f[3260] = 68086291;
f[3280] = 62727721;
f[3300] = 57657951;
f[3320] = 52868981;
f[3340] = 48352811;
f[3360] = 44101441;
f[3380] = 40106871;
f[3400] = 36361101;
f[3420] = 32856131;
f[3440] = 29583961;
f[3460] = 26536591;
f[3480] = 23706021;
f[3500] = 21084251;
f[3520] = 18663281;
f[3540] = 16435111;
f[3560] = 14391741;
f[3580] = 12525171;
f[3600] = 10827401;
f[3620] = 9290431;
f[3640] = 7906261;
f[3660] = 6666891;
f[3680] = 5564321;
f[3700] = 4590551;
f[3720] = 3737581;
f[3740] = 2997411;
f[3760] = 2362041;
f[3780] = 1823471;
f[3800] = 1373701;
f[3820] = 1004731;
f[3840] = 708561;
f[3860] = 477191;
f[3880] = 302621;
f[3900] = 176851;
f[3920] = 91881;
f[3940] = 39711;
f[3960] = 12341;
f[3980] = 1771;
f[4000] = 1;
}