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 java.util.ArrayList;
import java.util.Scanner;
//import java.io.*;
//import java.util.Arrays;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		//InputStreamReader is = new InputStreamReader(System.in);
		//BufferedReader br = new BufferedReader(is);
		//String text = scan.next();
		
		int x = 110000;
		ArrayList<Integer> searchList = new ArrayList<Integer>();
		ArrayList<Integer> primeList  = new ArrayList<Integer>();
		for(int i = 2; i <= x; i++) {
			searchList.add(i);
		}
		while(!searchList.isEmpty() && searchList.get(0) <= Math.sqrt(x)) {
			int primeNumber = searchList.get(0);
			primeList.add(primeNumber);
			
			for(int i = 0; i < searchList.size(); i++) {
				if(searchList.get(i) % primeNumber == 0) {
					searchList.remove(i);
					i--;
				}
			}
		}
		primeList.addAll(searchList);
		int[] sum = new int[primeList.size()];
		sum[0] = primeList.get(0);
		for(int i = 1; i < primeList.size(); i++) {
			sum[i] = sum[i-1] + primeList.get(i);
		}
		
		
        int n = scan.nextInt();
        while(n != 0){
            System.out.println(sum[n-1]);
            n = scan.nextInt();
        }
	}
}