require "prime"
arr = [0]
x = 2
while true
    if x.prime?
        arr << arr.last + x
    end
    x += 1
    break if arr.length == 10001
end

while true
    n = gets.to_i
    break if n == 0
    puts arr[n]
end
