#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
    int n;
    while(cin >> n,n){
        int count=0;
        int sosu=0;
        for(int i=2;;i++){
            if(count==n)
                break;
            if(i==2){
                sosu+=2;
                count++;
            }
            else{
                for(int j=2;j<i;j++){
                    if(i%j==0)
                        break;
                    if(j==i-1){
                        sosu+=i;
                        count++;
                        j=i;
                    }
                }
            }
        }
        cout << sosu << endl;
    }
}