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



while True:

    n = int(input())

    if not n:

        break

    i, num, sum = 0, 0, 0

    while num < n:

        if p[i] == 1:

            num += 1

            sum += i+1

        i += 1

    print(sum)
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



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

j = 0

for i in range(len(p)):

    if p[i]:

        prime[j] = i+1

        j += 1

        

while True:

    n = int(input())

    if not n:

        break

    print(sum(prime[:n]))
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
while True:
    n = int(input())
    if not n:
        break
    i, num, sum = 0, 0, 0
    while num < n:
        if p[i] == 1:
            num += 1
            sum += i + 1
        i += 1
    print(sum)

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
prime = [0 for i in range(11000)]
j = 0
for i in range(len(p)):
    if p[i]:
        prime[j] = i + 1
        j += 1
while True:
    n = int(input())
    if not n:
        break
    print(sum(prime[:n]))

+prime = [0 for i in range(11000)] +j = 0 +for i in range(len(p)): +    if p[i]: +        prime[j] = i + 1 +        j += 1 -    i, num, sum = 0, 0, 0 -    while num < n: -        if p[i] == 1: -            num += 1 -            sum += i + 1 -        i += 1 -    print(sum) +    print(sum(prime[:n]))