def isPrime(x):

    if x == 2:

        return True

    if x < 2 or x % 2 == 0:

        return False

    i, root_x = 3, int(pow(x, 0.5))

    while i <= root_x:

        if x % i == 0:

            return False

        i += 2

    return True



primes = [2]

for i in range(3, 104730):

    if isPrime(i):

        primes.append(primes[-1]+i)

while True:

    n = int(eval(input()))

    if n == 0:

        break

    print((primes[n-1]))
primes = [0, 0] + [1] * 150000

for i in range(2, 388):

    if primes[i]:

        for j in range(i*i, 150001, i):

            primes[j] = 0



values = [i for i, v in enumerate(primes) if v]

while True:

    n = int(eval(input()))

    if n == 0:

        break

    print((sum(values[:n])))
def isPrime(x):
    if x == 2:
        return True
    if x < 2 or x % 2 == 0:
        return False
    i, root_x = 3, int(pow(x, 0.5))
    while i <= root_x:
        if x % i == 0:
            return False
        i += 2
    return True


primes = [2]
for i in range(3, 104730):
    if isPrime(i):
        primes.append(primes[-1] + i)
while True:
    n = int(eval(input()))
    if n == 0:
        break
    print((primes[n - 1]))

primes = [0, 0] + [1] * 150000
for i in range(2, 388):
    if primes[i]:
        for j in range(i * i, 150001, i):
            primes[j] = 0
values = [i for i, v in enumerate(primes) if v]
while True:
    n = int(eval(input()))
    if n == 0:
        break
    print((sum(values[:n])))

-def isPrime(x): -    if x == 2: -        return True -    if x < 2 or x % 2 == 0: -        return False -    i, root_x = 3, int(pow(x, 0.5)) -    while i <= root_x: -        if x % i == 0: -            return False -        i += 2 -    return True - - -primes = [2] -for i in range(3, 104730): -    if isPrime(i): -        primes.append(primes[-1] + i) +primes = [0, 0] + [1] * 150000 +for i in range(2, 388): +    if primes[i]: +        for j in range(i * i, 150001, i): +            primes[j] = 0 +values = [i for i, v in enumerate(primes) if v] -    print((primes[n - 1])) +    print((sum(values[:n])))