#include <iostream>
#include <array>


class prime
{
public:
    static void calc_prime() {//??????????´???°?????????????±????????????????
        
        numbers.at(0) = false;//??????????´???°??§???????????§false;
        for (int i = 1; i < max_prime; i++) {//????????¶true??§?????????
            numbers.at(i) = true;
        }
        
        for (int i = 2; i <= max_prime; i++) {
            if (numbers.at(i - 1) == true) {//??????i????´???°?????£??????
                static int prime_found = 0;
                prime_numbers.at(prime_found) = i;//?´???°?????§????????????
                prime_found++;
                
                for(int baisu = i; baisu <= max_prime; baisu +=i) {//?????°????±???????
                    numbers.at(baisu - 1) = false;//false????????????
                }
            }
        }
        
    }
    
    static int get_prime(int n) {
        return prime_numbers.at(n-1);
    }
    
private:
    static const int max_prime = 104729;
    static std::array<int, 104729> numbers;//.at(i)??????i+1?????\????????????
    static std::array<int, 10000> prime_numbers;//.at(i)??????i+1??????????´???°?????\????????????
};
std::array<int, 104729> prime::numbers;
std::array<int, 10000> prime::prime_numbers;
int main()
{
    int input;
    std::cin >> input;
    
    prime::calc_prime();//?????????
    
    while(input !=0) {
        int sum = 0;
        for (int i = 1; i <= input; i++) {
            sum += prime::get_prime(i);
        }
        std::cout << sum << std::endl;
        std::cin >> input;
    }
}