Problem:
Score : 1200 points

Problem Statement

There are infinitely many cards, numbered 1, 2, 3, ...
Initially, Cards x_1, x_2, ..., x_N are face up, and the others are face down.

Snuke can perform the following operation repeatedly:

Select a prime p greater than or equal to 3. Then, select p consecutive cards and flip all of them.

Snuke's objective is to have all the cards face down.
Find the minimum number of operations required to achieve the objective.

Constraints

1 ≤ N ≤ 100

1 ≤ x_1 < x_2 < ... < x_N ≤ 10^7

Input

Input is given from Standard Input in the following format:

N
x_1 x_2 ... x_N

Output

Print the minimum number of operations required to achieve the objective.

Sample Input 1

2
4 5

Sample Output 1

2

Below is one way to achieve the objective in two operations:

Select p = 5 and flip Cards 1, 2, 3, 4 and 5.

Select p = 3 and flip Cards 1, 2 and 3.

Sample Input 2

9
1 2 3 4 5 6 7 8 9

Sample Output 2

3

Below is one way to achieve the objective in three operations:

Select p = 3 and flip Cards 1, 2 and 3.

Select p = 3 and flip Cards 4, 5 and 6.

Select p = 3 and flip Cards 7, 8 and 9.

Sample Input 3

2
1 10000000

Sample Output 3

4

Solution in C++ (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>
#define ll long long
#define met(a) memset(a,0,sizeof(a))
#define inf 0x3f3f3f3f
using namespace std;
const int mod=1e9+7;
ll a[110];
int b[25]= {3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
bool cmp(int x,int y)
{
    return x>y;
}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    met(a);
    int i,j,k,m,n,cnt=0,ans=0;
    cin>>n;
    for(i=1; i<=n; i++)
        cin>>a[i];
    sort(a+1,a+1+n);
    for(i=0; i<24; i++)
    {
        if(n%b[i]==0)
        {
            cout<<n/b[i];
            return 0;
        }
    }
    for(i=2; i<=n; i++)
    {
        if(a[i]==a[i-1]+1)
        {
            cnt++;
            if(i==n)
                ans+=2;
        }
        else
        {
            ans+=2;
        }
    }
    cout<<ans<<endl;
    return 0;
}