#include<iostream>
using namespace std;

typedef long long ll;

const int pMax = 10000;
ll prime[pMax];
bool is_prime[200010];

void sieve(ll n) {
	int p = 0;
	for (ll i = 0; i <= n; i++) is_prime[i] = true;
	is_prime[0] = is_prime[1] = false;
	for (ll i = 2; i <= n; i++) {
		if (is_prime[i]) {
			prime[p++] = i;
			if (p == pMax) return;
			for (ll j = 2 * i; j <= n; j += i) is_prime[j] = false;
		}
	}
}
int main() {
	sieve(200000);
	int n;
	while (cin >> n && n) {
		ll s = 0;
		for (int i = 0; i < n; i++) {
			s += prime[i];
		}
		cout << s << endl;
	}
}
