#include <iostream>
using namespace std;

/** Problem0044 : Prime Number II **/
#define MAX 110000
int main()
{
	bool prime[MAX];
	int  input;
	unsigned sum, num;
	
	for (int i=0; i<MAX; i++)
		prime[i] = true;
	
	prime[0] = false; prime[1] = false;
	
	for (int i=2; i<MAX; i++) {
		if (prime[i]) {
			for (int j=2; i*j<MAX; j++) {
				prime[i*j] = false;
			}
		}
	}
	
	while (cin >> input) {
		if (input == 0) break;
		sum=0; num=0;
		for (int i=2; num<input; i++) {
			if (prime[i]) {
				sum += i;
				num++;
			}
		}
		cout << sum << endl;
	}
	return 0;
}