#include<iostream>
#include<math.h>
using namespace std;
int pnum[10000] = {0};
int psum[10000] = {0};
int main(){
int i,j,pcor = 0;
int root;
for(i = 2;i < 10001;i++){
root = (int)sqrt(double(i))+1;
for(j = 0;j < pcor && pnum[j] <= root;j++){
if(i% pnum[j]==0)break;
}
if(j == pcor || pnum[j] > root){
pnum[pcor] = i;
pcor++;
}
}
for(i = 0;i < pcor;i++){
if(i == 0)
psum[i] = pnum[i];
else
psum[i] = pnum[i]+psum[i-1];
}
int N,data[50000];
int dcor = 0;
while(1){
cin >> N;
if(N == 0)
break;
data[dcor] = psum[N-1];
dcor++;
}
for(i = 0;i <= dcor;i++){
cout << data[i] << endl;
}
return 0;
}