#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;

// 𝑂(𝑁*log(log 𝑁))
vector<int> eratosthenes(int N)
{
    vector<int> res;
    vector<bool> prime(N + 1, 1);
    prime[0] = prime[1] = false;
    for (int i = 2; i * i <= N; ++i)
    {
        if (prime[i] == true)
        {
            for (int j = 2 * i; j <= N; j += i)
            {
                prime[j] = false;
            }
        }
    }
    for (int i = 0; i <= N; ++i)
    {
        if (prime[i] == true)
            res.push_back(i);
    }
    return res;
}

ll n;

int main()
{
    auto p = eratosthenes(100000000);
    while (cin >> n)
    {
        if (n == 0)
            return 0;
        ll ans = 0;
        for (int i = 0; i < n; i++)
        {
            ans += p[i];
        }
        cout << ans << endl;
    }
}

