#include <iostream>
using namespace std;

const int max_n = 10000;
int prime[max_n];
bool is_prime[max_n+1];

int sieve()
{
	int n = max_n;
	int p = 0;
	for(int i=0;i<=n;i++){
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	for(int i=2;i<=n;i++){
		if(is_prime[i]){
			prime[p++] = i;
			for(int j=2*i;j<=n;j+=i)
				is_prime[j] = false;
		}
	}
	return p;
}

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