import std.stdio;
import std.string;
import std.conv : to;
import std.algorithm : fill;
import std.math : sqrt;



void main() {
    int input;
    immutable limitList = 200000;
    bool[] listNumbers = new bool[](limitList);
    int[] listPrimeNumbers;

    listNumbers.fill(true);
    foreach (i; 2..limitList.to!double.sqrt.to!int) {
        if (listNumbers[i]) {
            for (int j = i*2; j < limitList; j += i) listNumbers[j] = false;
        }
    }

    foreach (i; 2..listNumbers.length) {
        if (listNumbers[i]) {
            listPrimeNumbers ~= i.to!int;
        }
    }

    while ((input = readln.chomp.to!int) != 0) {
        ulong sum = 0;

        foreach (i; 0..listPrimeNumbers.length) {
            if (i == input) break;
            sum += listPrimeNumbers[i];
        }

        writeln(sum);
    }
}