Yes, Prime Minister
시간 제한10초메모리 제한512 MB
각 x에 대해 x를 포함하면서 연속한 정수의 합이 소수가 되는 가장 짧은 구간 [l, r]의 길이를 구하고, 없으면 -1을 출력한다.
문제
Mr. Hacker's Department of Administrative Affairs (DAA) has an infinite amount of civil servants. Every integer is used as an ID (identification number) by exactly one civil servant. Mr. Hacker is keen on reducing overmanning in civil service, so he will only keep people with consecutive IDs in , and dismiss all the others.
However, permanent secretary Sir Humphrey's ID is , and he cannot be kicked out, so must hold. Mr. Hacker wants to be Prime Minister, so he demands that the sum of people's IDs must be a prime number.
You, Bernard, need to make the reduction plan which meets the demands of both bosses. Otherwise, Mr. Hacker or Sir Humphrey will fire you.
Mr. Hacker would be happy to keep as few people as possible. Please calculate the minimum number of people left to meet their requirements.
A prime number is an integer greater than that has no positive integer divisors other than and .
입력
The first line contains an integer (), the number of test cases. Then test cases follow.
The first and only line of each test case contains one integer (), the ID of Sir Humphrey.
출력
For each test case, print a line with one integer: the minimal number of people kept if such a plan exists, or otherwise.