import Control.Monad

main = do
  n <- readLn
  unless (n==0) $ do
    print $ sum.take n $ primes
    main

primes :: [Int]
primes = 2 : filter isPrime [3,5..]
isPrime :: Int -> Bool
isPrime n = foldr ((&&).(/= 0).mod n) True $ takeWhile (<=sqrtn) primes
  where sqrtn = floor.sqrt.fromIntegral $ n