#include<iostream>
using namespace std;
bool notp[105001] = {true,true,false};
int primearr[10001];
void prime(){
	int i,j,cnt=0;
	i=2;
	while(i<=10001){
		primearr[cnt] = i;
		cnt++;
		j=i*i;
		while(j<=105001){
			notp[j] = true;
			j += i;
		}
		i++;
		while(i<=10001){
			if(notp[i] == false) break;
			i++;
		}
	}
}

int main(){
	int i, n, sum;
	prime();
	while(true){
		cin>>n; if(n==0) break;
		sum=0;
		for(i=0;i<n;i++){
			sum+=primearr[i];
		}
		cout<<sum<<endl;
	}
	return 0;
}