#include <iostream>
#define x 200000
using namespace std;
int main(){
	int p[x+1];
	bool q[x+1];
	for(int i=2;i<=x;i++) q[i] = true;
	for(int i=2;i<=x;i++){
		if(not q[i]) continue;
		for(int j=2;j<=x/i;j++) q[i*j] = false;
	}
	int c = 0;
	for(int i=2;i<=x;i++) if(q[i]) p[c++] = i;

	int n;
	while(1){
		cin >> n;
		if(n==0) break;
		int b = 0;
		for(int i=0;i<n;i++) b+=p[i];
		cout << b << endl;
	}
}