using System;
class torikainoakaunntonanndakke
{
    static void Main()
    {
        int[] a = new int[10000];
        a[0] = 2;
        int z = 1;
        int g = 2;
        for(;; )
        {
            for(int m = 0; m < z; m++)
            {
                if (g % a[m] == 0)
                    goto stop;
            }
            a[z] = g;
            z++;
            stop:;
            if (g % 2 == 0)
                g++;
            else
                g += 2;
            if (z == 10000)
                break;
        }
        ulong[] k = new ulong[50];
        int j = 0;
        while (true)
        {
            int b = int.Parse(Console.ReadLine());
            if (b == 0) break;
            ulong c = 0;
            for(int i = 0; i < b; i++)
                c += (ulong)a[i];
            k[j] = c;
            j++;
        }
        for(int i = 0; i < j; i++)
        {
            Console.WriteLine(k[i]);
        }
    }
}