
while true
	n = gets.chomp!.to_i
	if n == 0
	break
	end
	a = Array.new()

	a[0] =  2
	for i in 1..n-1
		num = a[-1] + 1
		while  sub_prime(a,num) == false 
			num += 1
		end

		a.push(num)
	end

	puts calc_sum(a)
end



def calc_sum(ary)
	sum = 0
	for x in ary
	
		sum += x
	end
	sum
end




def sub_prime(ary,num)
	test = true
	for x in ary
		if  test == false
			break
		end

		if num % x == 0
			test = false
		end
	end
	return test

end