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

int main() {
  int n;
  vector<int> pri(1000000, 1);
  vector<int> p_sum;
  pri[0] = 0;
  pri[1] = 0;

  for(int i = 2; i < sqrt(1000000); i++) {
    for(int j = i*i; j < 1000000; j+=i) {
      pri[j] = 0;
    }
  }

  int cnt	= 0;
  p_sum.push_back(2);

  for(int i = 3; i < 1000000; i++) {
    if(pri[i] == 1) {
      p_sum.push_back(i+p_sum[cnt]);
      cnt++;
    }   
  }

  while(cin >> n, n) {
    cout << p_sum[n-1] <<	endl;
  }
  return 0;
}

