#include<bits/stdc++.h>

using namespace std;

long long int ar[1000000],m[1000000],m2[1000000];

void _seive_ (long long int n)
{
    long long int i,j;
    for (i=2;i<=n;++i){

        for (j=(i*i);j<=n;j+=i){

            ar[j-1]=1;

        }
    }
    j=0;
    m2[1]=2;
    for (i=2;i<=n;++i){

        if(ar[i-1]==0){

            ++j;
            m[j]=i;
            if(j>1){

                m2[j]= m[j]+m2[j-1];

            }
        }
    }

    return ;
}

int main()
{
   long long int num;

   _seive_(1000000);
   while(scanf("%lld",&num)==1 && num!=0) {

        cout<<m2[num]<<endl;

   }

   return 0;

}


































