#include <bits/stdc++.h>
using namespace std;

int main(void){
    int n,flag=0;
    std::deque<int> deq;
    deq.emplace_back(2);
    for (int i=3;deq.size()<=10000;i+=2) {
            double sqrtNum=sqrt(i);
            for (int j=3;j<=sqrtNum;j+=2) {
                if (i%j==0) {
                    flag=1;
                    break;
                }
            }
            if (flag==0) {
                deq.emplace_back(i);
            } else {
                flag=0;
            }
        }
    while (cin>>n) {
        if (n==0) {
            break;
        } else {
            int sum=0;
            for (int k=0;k<n;k++) {
                sum+=deq[k];
            }
            cout<<sum<<endl;
        }
    }
}
