import math



r = 105000

sqrt = int(math.sqrt(r))

p = [1]*r

p[0] = 0

for i in range(1,sqrt):

    if p[i]:

        for j in range(2*i+1,r,i+1):

            p[j] = 0



s = [0 for i in range(11000)]

s[0] = 2

k = 1

for i in range(2,r):

    if p[i]:

        s[k] = i+1+s[k-1]

        k += 1

        

while True:

    n = int(input())

    if not n:

        break

    print(s[n-1])
import math



r = 105000

sqrt = int(math.sqrt(r))

p = [1]*r

p[0] = 0

for i in range(1,sqrt):

    if p[i]:

        p[2*i+1::i+1] = [0 for x in range(2*i+1,r,i+1)]



s = [0 for i in range(11000)]

s[0] = 2

k = 1

for i in range(2,r):

    if p[i]:

        s[k] = i+1+s[k-1]

        k += 1

        

while True:

    n = int(input())

    if not n:

        break

    print(s[n-1])
import math

r = 105000
sqrt = int(math.sqrt(r))
p = [1] * r
p[0] = 0
for i in range(1, sqrt):
    if p[i]:
        for j in range(2 * i + 1, r, i + 1):
            p[j] = 0
s = [0 for i in range(11000)]
s[0] = 2
k = 1
for i in range(2, r):
    if p[i]:
        s[k] = i + 1 + s[k - 1]
        k += 1
while True:
    n = int(input())
    if not n:
        break
    print(s[n - 1])

import math

r = 105000
sqrt = int(math.sqrt(r))
p = [1] * r
p[0] = 0
for i in range(1, sqrt):
    if p[i]:
        p[2 * i + 1 :: i + 1] = [0 for x in range(2 * i + 1, r, i + 1)]
s = [0 for i in range(11000)]
s[0] = 2
k = 1
for i in range(2, r):
    if p[i]:
        s[k] = i + 1 + s[k - 1]
        k += 1
while True:
    n = int(input())
    if not n:
        break
    print(s[n - 1])

-        for j in range(2 * i + 1, r, i + 1): -            p[j] = 0 +        p[2 * i + 1 :: i + 1] = [0 for x in range(2 * i + 1, r, i + 1)]