#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const int MAX_N = 1e8;
bool isPrime(ll x)
{
    if(x % 2 == 0) return false;
    for(ll i = 3; i * i <= x; i += 2) if(x % i == 0) return false;
    return true;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    vector<ll> prime;
    prime.push_back(2);
    for(ll x = 3; prime.size() < 10010; x += 2) if(isPrime(x)) prime.push_back(x);
    vector<ll> sum(10010, 0);
    for(int i = 1; i < 10010; i++) sum[i] += sum[i - 1] + (ll)prime[i - 1];
    while(cin >> n, n)
    {
        cout << sum[n] << endl;
    }
    return 0;
}


