#include <iostream>
#define MAX 10000
using namespace std;

int P[MAX], S[MAX];

bool isprime(int n){
    if (n == 2) return true;
    if (n % 2 == 0) return false;
    for ( int i = 3; i * i <= n; i += 2 ) {
        if (n % i == 0) return false;
    }
    return true;
}

void setP() {
    P[0] = 2;
    int i = 3, n = 1;
    while(n < MAX) {
        if(isprime(i)) {
            P[n] = i;
            n++;
        }
        i += 2;
    }
    return;
}

void setS() {
    S[0] = 2;
    for(int i = 1; i < MAX; i++) {
        S[i] = S[i - 1] + P[i];
    }
    return;
}

int main(void) {
    setP(); setS();
    int n;
    while(cin >> n){
        if (n == 0) return 0;
        cout << S[n - 1] << endl;
    }
}
