**15 人解决**，15 人已尝试。

**17 份提交通过**，共有 21 份提交。

**3.0** EMB 奖励。

**单点时限: **8.0 sec

**内存限制: **256 MB

The sequence of consecutive composite numbers (positive integers that are not prime and not equal to ) lying between two successive prime numbers and is called a prime gap of length . For example, between and is a prime gap of length .

Your mission is to write a program to calculate, for a given positive integer , the length of the prime gap that contains . For convenience, the length is considered in case no prime gap contains .

The input is a sequence of lines each of which contains a single positive integer. Each positive integer is greater than and less than or equal to the -th prime number, which is . The end of the input is indicated by a line containing a single zero.

The output should be composed of lines each of which contains a single non-negative integer. It is the length of the prime gap that contains the corresponding positive integer in the input if it is a composite number, or otherwise. No other characters should occur in the output.

Input

10 11 27 2 492170 0

Output

4 0 6 0 114

**15 人解决**，15 人已尝试。

**17 份提交通过**，共有 21 份提交。

**3.0** EMB 奖励。

题目标签