#include <cmath>
#include <iostream>
#include <vector>
typedef std::vector <int> vi;
vi P;
vi prime(int n){
	int i=0,j=1,h=(n+1)/2,x,r=(int)pow(n,.5);
	vi s(h),p(1);
	while(j<=n){
		s[i++]=j;
		j+=2;
	}
	p[0]=2;
	for (i=1;i<h;i++)
		if (x=s[i]){
			p.push_back(x);
			if (i<=r) for (j=x*x/2;j<h;j+=x) s[j]=0;
		}
	return p;
}
int main(void){
	int n,s;
	P=prime(105000);
	while (true){
		std::cin>>n; if (n==0) break;
		for (s=0;n--;) s+=P[n];
		std::cout<<s<<"\n";
	}
}