#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;
typedef long long ll;

int main(){
    
    const int N = 200000;
    int sosu[N];
    int ans[10000];
    int cnt = 0;
    int sum = 0;
    
    for(int i = 0;i < N; ++i){
        sosu[i] = i;
    }
    
    for(int i = 2;i < N; ++i){
        if(sosu[i]){
            sum += sosu[i];
            ans[cnt] = sum;
            ++cnt;
            if(cnt == 10000)break;
            for(int j = i*i; j < N; ++j){
                if(sosu[j] && (sosu[j] % sosu[i] == 0)){
                    sosu[j] = 0;
                }
            }
        }
    }
    
    ll n;
    while(1){
        cin >> n;
        if(!n)break;
        
        cout << ans[n-1] << endl;
    }
    
    return 0;
}