#include <iostream>
#include <algorithm>
using namespace std;

int n = 100;

int main() {
int N;
int num =0;
int sum[n];
for (int i = 0; i < n+1; i++) {
  sum[i] = 0;
  }

while((cin >> N)&&(N >0)){

int count = 0;
int a[n+1];

for (int i = 0; i < n+1; i++) {
  a[i] = i;
  }
  
for (int j = 2; j < n+1; j++) {
  for (int k = j+1; k < n+1; k++){
    if ((a[k] % j) == 0){
	  a[k] = 0;
	  }
  }
}

sort(a, a+n);

for (int l = 0; l < n; l++){
  if ((a[l] != 0)&&(a[l] != 1)){
  sum[num] += a[l];
  count++;
  }
  if (count == N) break;
  }
  
  num++;
}

for (int i = 0; i < num; i++){
cout << sum[i] << endl;
}
}
  