#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

bool Prime(int in){
	for (int i = 3; i <= sqrt(in); i += 2){
		if (in%i == 0)	return false;
	}
	return true;
}

vector<int> kakunou(vector<int> in){
	in.push_back(2);
	in.push_back(3);

	for (int i = 5;; i += 2){
		if (Prime(i))	in.push_back(i);
		if (in.size() >= 10000)	break;
	}

	return in;
}

int main(){
	int in, sum = 0;
	vector<int> vec;
	vec = kakunou(vec);
	while (cin >> in, in){
		sum = 0;
		vector<int>::iterator it = vec.begin();
		for (int i = 0; i < in; i++){
			sum += *it;
			++it;
		}
		cout << sum << endl;
	}

	return 0;
}