require 'matrix'

prime = [2]
for i in 3..200001
flag = true
  for j in 2..Math.sqrt(i)
if i%j == 0 
flag = false
break
end
  end
if flag
prime.push(i)
end
end

loop do
n = gets.to_i
if n==0
break
end
sum = 0
for i in 0..n-1
sum += prime[i]
end
puts sum
end