#include <iostream>
#include <algorithm>

#define N 105000

using namespace std;

int main()
{
  int n = 0;
  bool prime[N];

  fill(prime, prime+N, true);

  for(int i = 2; i < N; ++i){
    if(prime[i])
      for(int j = i+i; j < N; j += i)
	prime[j] = false;
  }

  while(cin>>n && n){
    int sum = 0;

    for(int i = 2; i < N; ++i){
      if(prime[i]){
	sum += i;
	if(--n == 0) break;
      }
    }

    cout << sum << endl;
  }

  return 0;
}