Let p (i) be the i-th prime number from the smallest. For example, 7 is the fourth prime number from the smallest, 2, 3, 5, 7, so p (4) = 7.

Given n, the sum of p (i) from i = 1 to n s

s = p (1) + p (2) + .... + p (n)

Create a program that outputs. For example, when n = 9, s = 2 + 3 + 5 + 7 + 11 + 13 + 17 + 19 + 23 = 100.



Input

Given multiple datasets. Each dataset is given the integer n (n ≤ 10000). When n is 0, it is the last input. The number of datasets does not exceed 50.

Output

For n in each dataset, print s on one line.

Example

Input

2
9
0


Output

5
100
import math
MAX=104729
ROOT=int(math.sqrt(MAX))

#素数以外をはじく
prime=[True for i in range(MAX+1)]

def prime_list(prime):
    #2は除外
    for i in range(2,MAX,2):
        prime[i]=False
    #要素を持つか
    for x in range(3,ROOT+1):
        if prime[x]==True:
            for j in range(x*x,MAX,x):
                prime[j]=False
                
prime_list(prime)

total=[0 for g in range(MAX)]
def append(total):
    j=total[1]=2
    for i in range(3,len(prime)):
        if prime[i]==True:
            total[j]+=total[j-1]+i
            j+=1

append(total)


while True:
    n=int(input())
    if n==0:
        break
    print(total[n])



