
import std.stdio, std.string;

long[] make_prime_sum_stream(int n) {
  int i = 2;
  long[] prime_stream = [2];
  long[] sum_stream = [2];
  int sum = 2;
  do {
  next:
    i += 1;
    for(int j = 0; prime_stream[j] * prime_stream[j] <= i; j++) {
      if ((i % prime_stream[j]) == 0) goto next;
    }
    sum += i;
    sum_stream ~= sum;
    prime_stream ~= i;
  } while(prime_stream.length <= n);
  return sum_stream;
}

void main() {
  long[] primes = make_prime_sum_stream(10000);
  for(int n; readf("%d\n", &n), n != 0;)
    writeln(primes[n - 1]);
}