#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define FIND(c, n)      std::find((c).begin(), (c).end(), (n));
#define BSEARCH(c, n)   std::binary_search((c).begin(), (c).end(), (n))
#define LLPOW(p1,p2)    ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)       fgets((p), sizeof(p), stdin)
#define CHOMP(p)        do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)

typedef long long ll;
typedef unsigned long long ull;

#ifdef _DEBUG
#define pf printf
#define pr(n) do { cout << #n " = " << (n) << endl; } while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif

void prime_list(vector<unsigned int> &plist, unsigned int max_prime){

    if(plist.size() && plist[plist.size()-1] >= max_prime ) return;
    if(max_prime <= 2){
        plist.push_back(2);
        return;
    }

    unsigned int rt = int(sqrt((double)max_prime));
    prime_list(plist, rt);

    unsigned int bias = plist[plist.size()-1] + 1;
    if(bias == 3) bias = 2;
    unsigned int num = (max_prime - bias + 1) / 2;
    if(num == 0) return;

    char *l = new char[num];
    memset(l, 1, num);

    FOREACH(it, plist){
        unsigned int prime = *it;
        if(prime > rt) break;
        unsigned int st = max(rt - (rt % prime), prime);
        for(unsigned int i = st; i <= max_prime; i += prime){
            if(i >= bias){
                unsigned int idx = i - bias;
                if(idx % 2 == 1){
                    l[idx/2] = 0;
                }
            }
        }
    }
    for(unsigned int i = 0; i < num; i++){
        if(l[i]){
            plist.push_back(bias + 1 + i * 2);
        }
    }
    delete l;
    return;
}

int main(){
    vector<unsigned int> v;
    unsigned int n = 2;
    while(v.size() < 10010){
        n = n * 2;
        prime_list(v, n);
    }

    unsigned int t = 0;
    REP(i, 10000){
        unsigned int tv = v[i];
        v[i] += t;
        t += tv;
    }

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

    return 0;
}