#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

bool is_prime(int n) {
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) return false;
  }
  return n != 1;
}

int main() {
  ll sum[10001];
  sum[0] = 0;
  int cnt = 1, val = 1;
  while (cnt <= 10000) {
    while (!is_prime(val)) val++;
    sum[cnt] = sum[cnt - 1] + val;
    cnt++, val++;
  }
  int n;
  while (cin >> n && n) {
    cout << sum[n] << endl;
  }
  return 0;
}
