{-# OPTIONS_GHC -O3 -fexpose-all-unfoldings -fdicts-cheap -fdicts-cheap #-}

import Data.Array (array,(!))

main = do
  s <- readLn
  if s == 0
     then return ()
     else do
      print $ primeArr ! s
      main

primes :: [Integer]
primes = 2:3: filter isPrime [5,7..]

isPrime :: Integer -> Bool
isPrime n = all ((>0).(rem n)) $ takeWhile (\x -> x * x <= n) primes

primeArr = array (1,10000) [(i, pr)|i <- [1..10000] , let pr = sum (take i primes)]