#include<iostream>
using namespace std;

int prime[10000];

void GetPrime(int kosuu);
int main(){
	int n,sum[1000] = {0},cor = 0;
	GetPrime(10000);
	while(cin >> n){
		if(n == 0)
			break;
		for(int i = 0;i < n;i++){
			sum[cor] += prime[i];
		}
		cor++;
	}
	for(int i = 0;i < cor;i++){
		cout << sum[i] << endl;
	}
	return 0;
}

void GetPrime(int kosuu){
	int i,j,count = 0;
	for(i = 2;count < kosuu;i++){
		for(j = 0;j < count;j++){
			if(i%prime[j] == 0)
				break;
		}
		if(j < count)
			continue;
		prime[count] = i;
		count++;
	}
}