#include <iostream>
using namespace std;

int n, i = 1, p = 3;
int a[10000];

int main()
{
	a[0] = 2;

	while (i < 10000) {
		int j = 3;

		while (j * j <= p) {
			if (p % j == 0)
				break;

			j += 2;
		}

		if (j * j > p) {
			a[i] = a[i - 1] + p;
			i++;
		}

		p += 2;
	}

	cin >> n;

	while (n > 0) {
		cout << a[n - 1] << endl;

		cin >> n;
	}

	return 0;
}
