#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<complex>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    const int lim = 200000;
    int table[lim] = {0};
    table[0] = table[1] = 1;
    rrep(i, 2, sqrt(lim)) {
        int j = i + i;
        while (j < lim) {
            table[j] = 1;
            j += i;
        }
    }
    vector<int> v;
    rep(i, lim) if (table[i] == 0) v.push_back(i);
    //rep(i, v.size()) cout << v[i] << " "; cout << endl;
    int n;
    while (cin >> n && n) {
        int ans = 0;
        rep(i, n) ans += v[i];
        cout << ans << endl;
    }
}



