#include<iostream>
#include<math.h>
using namespace std;

int main() {
	bool prime[10001];
	for (int i = 0; i <= 10000; i++) {
		prime[i] = true;
	}
	for (int i = 2; i <= sqrt(10000); i++) {
		if (prime[i]) {
			for (int j = 2; j*i <= 10000; j++) {
				 prime[j*i] = false;
			}
		}
	}
	for (int i = 2; i < 10001; i++) {
		if (prime[i])cout << i << endl;
	}
	int n; int sum;
	while (cin >> n) {
		if (n==0)break;
		sum = 0; int count = 0;
		for(int i=2;;i++){
			if (prime[i]) { sum += i; count++; }
			if (count == n)break;
		}
		cout << sum << endl;
	}
}
