//56
#include<iostream>
#include<vector>

using namespace std;

int main(){
  vector<int> prime;
  vector<int> psum(1,0);
  for(int i=2;prime.size()<10000;i++){
    int j;
    for(j=0;j<prime.size();j++){
      if(i%prime[j]==0)break;
    }
    if(!(j<prime.size())){
      prime.push_back(i);
      psum.push_back(psum.end()[-1]+i);
    }
  }
  for(int n;cin>>n,n;){
    cout<<psum[n]<<endl;
  }
  return 0;
}