#include <iostream>
using namespace std;

int main()
{
	bool p[10001] = {false};

	for (int i = 2; i * i < 10001; i++){
		for (int j = i * i; j < 10001; j += i){
			p[j] = true;
		}
	}

	int n;
	while (cin >> n, n){
		int c = 0, sum = 0;

		for (int i = 2; c != n; i++){
			if (!p[i]){
				sum += i;
				c++;
			}
		}

		cout << sum << endl;
	}

	return (0);
}