#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int p[110000 + 1];
    rep(i, 110000 + 1) p[i] = 1;
    p[0] = 0, p[1] = 0;
    for (int i = 2; i <= (int)sqrt(110000); i++)
    {
        if (p[i] == 1)
        {
            for (int j = 2; i * j <= 110000; j++)
            {
                p[i * j] = 0;
            }
        }
    }
    int n;
    while (cin >> n, n)
    {

        int sum = 0;
        int cnt = 0;
        for (int i = 2; i <= 110000; i++)
        {
            if (p[i] == 1)
            {
                cnt++;
                sum += i;
                if (cnt == n)
                {
                    break;
                }
            }
        }
        OP(sum);
    }
    return 0;
}
