#include <iostream>
#include <cstdio>
#define MAX_N 10010
using namespace std;
typedef long long ll;
bool prime[MAX_N];

bool isPrime(int num) {
    for(int r = 2; r * r <= num; r++) {
        if(num % r == 0) return(false);
    }
    return(true);
}

void init() {
    fill(prime, prime + MAX_N, true);
    prime[0] = prime[1] = false;
    for(int r = 2; r * r <= MAX_N; r++) {
        if(isPrime(r)) {
            for(int c = r * 2; c <= MAX_N; c+=r) prime[c] = false;
        }
    }
}

int main(void) {
    init();
    int input;
    while(cin >> input, input != 0) {
        ll sum = 0;
        for(int r = 2; r <= MAX_N && input; r++) {
            if(prime[r]){ sum += r; input--;}
        }
        cout << sum << endl;
    }
    return(0);
}