#include <cstring>
#include <iostream>
using namespace std;
typedef long long ll;

const int MAX_N = 10001;
int n;
bool sieve[MAX_N];

void solve() {
  int count = 0;
  ll res = 0;
  for (int i = 2; i < MAX_N; i += 1) {
    if (sieve[i]) {
      res += i;
      count++;
    }
    if (count == n) {
      break;
    }
  }
  cout<<res<<endl;
}

int main (int argc, char const* argv[]) {
  // set sieve
  memset(sieve, true, sizeof sieve);
  for(int i=4;i<MAX_N;i+=2) sieve[i] = false;

  for(int i=3;i<MAX_N;i+=2)
  if (sieve[i])
  for(int j=i+i;j<MAX_N;j+=i)
  if (sieve[j])
  sieve[j] = false;
  
  while (cin>>n, n) {
    solve();
  }
  
  return 0;
}