#include <cstdio>
#include <vector>
using namespace std;

int prime[10001];

void init()
{
    for (int i = 0; i < 10001; i++) prime[i] = 0;
    prime[0] = 1;
    prime[1] = 1;
    for (int i = 4; i < 10001; i += 2) prime[i] = 1;
    for (int i = 3; i < 10001; i += 2) {
        if (prime[i] == 1) continue;
        for (int j = i + i; j < 10001; j += i) prime[j] = 1;
    }
}

int main()
{
    init();
    vector<int> p;
    for (int i = 2; i < 10001; i++) {
        if (prime[i] == 1) continue;
        p.push_back(i);
    }
    int n;
    while (scanf("%d", &n) && n != 0) {
        int sum = 0;
        for (int i = 0; i < n; i++)
            sum += p[i];
        printf("%d\n", sum);
    }
}