primes = Enumerator.new {|y|
	ps = [2]
	cp = 3
	y << 2
	while true 
		if ps.take_while {|x|
			x*x <= cp
		}.all? {|x|
			cp % x != 0
		}
			y << cp
			ps.push cp
		end
		cp+=2
	end
}

while (n = gets.to_i)!= 0
	puts primes.take(n).inject(:+)
end