#include<cstdio>
#include<math>
using namespace std;

int main(){
	int n,i,j,p[10000],sum=0;
	while(scanf("%d",&n)!=0){
		for(i=2;;i++){
			for(j=2;j<=sqrt(i);j++){
			if(i%j==0)break;
			if(j==(int)sqrt(i)){p[n]=i;n--;break;}
			}
			if(n==0)break;
		}

		for(i=n;i>0;i--){sum += p[i];}
		printf("%d",sum);

	}

}