import std.stdio,std.string,std.conv;

int prime[1000000];

int main()
{
	prime[0] = prime[1] = 0;
	
	foreach(i;2..1000000)
	{
		prime[i] = 1;
	}
	foreach(i;2..1000000)
	{
		if(prime[i])
		{
			for(int j = i*2; j < 1000000 ;j += i)
			{
				prime[j] = 0;
			}
		}
	}

	int n;
	while(( n = readln.chomp.to!int) != 0)
	{
		int count = 0,ans = 0;
		foreach(i;0..1000000)
		{
			if(count == n) break;

			if(prime[i] == 1)
			{
				ans += i;
				count++;
			}
		}
		ans.writeln;
	}


	return 0;
}