#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 1000005

const int INF = 1e9+7;


/*素数のみの配列を返す*/
vector<ll> Eratosthenes(ll n,vector<ll>& arr){
 
    for(ll i = 0; i < n;i++){
        arr[i] = 1;
    }
 
    for(ll i = 2; i < sqrt(n); i++){
        if(arr[i]){
            for(ll j = 0; i * (j + 2) < n; j++){
                arr[i *(j + 2)] = 0;
            }
        }
    }
    vector<ll> prime;
    for(int i = 2;i < arr.size();i++){
        if(arr[i]){
            prime.push_back(i);
        }
    }
    return prime;
}

int main(){


    vector<ll> prime(ARRAY_MAX,0);
    prime = Eratosthenes(1e6,prime);
    
    for(int i = 0;i < prime.size()-1;i++){
        prime[i+1] += prime[i];
    }
    ll n;
    while(cin >> n,n){

        cout << prime[n-1] << endl;
    }








    return 0;
}
