prim=[True]*1000000

prim[0],prim[1]=False,False

for i in range(2,1000):

    if prim[i]:

        for j in range(i*2,1000000,i):

            prim[j]=False

prime=[i for i,j in enumerate(prim) if j==True]



while True:

    n=int(eval(input()))

    if n==0:

        break

    print((sum(prime[:n])))
prim=[True]*1000000

prim[0]=prim[1]=False

for i in range(2,350):

    if prim[i]:

        for j in range(i*2,110000,i):

            prim[j]=False

prime=[i for i,j in enumerate(prim) if j==True]



while True:

    n=int(eval(input()))

    if n==0:

        break

    print((sum(prime[:n])))
prim = [True] * 1000000
prim[0], prim[1] = False, False
for i in range(2, 1000):
    if prim[i]:
        for j in range(i * 2, 1000000, i):
            prim[j] = False
prime = [i for i, j in enumerate(prim) if j == True]
while True:
    n = int(eval(input()))
    if n == 0:
        break
    print((sum(prime[:n])))

prim = [True] * 1000000
prim[0] = prim[1] = False
for i in range(2, 350):
    if prim[i]:
        for j in range(i * 2, 110000, i):
            prim[j] = False
prime = [i for i, j in enumerate(prim) if j == True]
while True:
    n = int(eval(input()))
    if n == 0:
        break
    print((sum(prime[:n])))

-prim[0], prim[1] = False, False -for i in range(2, 1000): +prim[0] = prim[1] = False +for i in range(2, 350): -        for j in range(i * 2, 1000000, i): +        for j in range(i * 2, 110000, i):