#include "bits/stdc++.h"
using namespace std;

int main() {
	int n;
	vector<int> vi;
	int data[100010] = { 0 };
	for (int i = 0; i < 100005; ++i) {data[i] = i;}
	for (int i = 2; i <= sqrt(100005); ++i) {for (int j = i * 2; j <= 100005; j = j + i) {data[j] = 0;	}}
	for (int i = 2; i <= 100005; ++i) {if (data[i])vi.push_back(data[i]);}

	while (cin >> n) {
		if (!n)break;
		int sum = 0;
		for (int i = 0; i < n; ++i) {
			sum += vi[i];
		}
		cout << sum << endl;
	}
}