#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

/*
0 1 1   1
1 2 3   1+3
2 3 6   1+3+6
3 4 10  1+3+6+10
4 

1000 1+2+...+1001
1001 

2000 x
2001 0



*/


int main(){
	ll a[4][4010]={0};
	ll b[4][4010]={0};
	int n=4005;
	b[0][0]=1;
	rep(i,2001){
		if(i>1000) a[0][i]=1001-(i-1000);
		else a[0][i]=i+1;
		if(i) b[0][i]=b[0][i-1]+a[0][i];
	}
	n=3001;
	a[1][0]=1;
	b[1][0]=1;
	rep(i,n){
		if(i>2000) a[1][i]=a[1][i-1]-a[0][i-1001];
		else if(i>1000) a[1][i]=a[1][1000]-b[0][i-1001];
		else if(i) a[1][i]=a[1][i-1]+i+1;
		//else if(i) a[1][i]=a[1][i-1]+i+1;
		if(i) b[1][i]=b[1][i-1]+a[1][i];
	}
	a[2][0]=1;
	n=4001;
	rep(i,n){
		if(i>3000) a[2][i]=b[1][3000]-b[1][i-1000];
		else if(i>1000) a[2][i]=b[1][i]-b[1][i-1001];
		else if(i) a[2][i]=a[2][i-1]+a[1][i];
	}
	while(cin>>n){
		cout<<a[2][n]<<endl;
	}
	return 0;
}