#include <bits/stdc++.h>
using namespace std;

const int N=205,MX=10000010;
int n,m,mx,ma,mb,a[N],b[N],e[N][N],vis[N],lmat[N],rmat[N],B[MX],p[MX/10],ans;

void add(int x){if (x&1)  a[++ma]=x;  else  b[++mb]=x;}

bool dfs(int x)
{
	for (int y=1; y<=mb; y++)
		if ((e[x][y])&&(vis[y]!=vis[0]))
			{
				vis[y]=vis[0];
				if ((!rmat[y])||(dfs(rmat[y])))  return lmat[x]=y,rmat[y]=x,1;
			}
	return 0;
}

void work()
{
	scanf("%d",&n);
	for (int i=1,x,y=-1; i<=n+1; i++)
		{
			if (i<=n)  scanf("%d",&x),mx=max(mx,x+1);
			if ((i!=1)&&(y+1!=x))  add(y+1);
			if ((i<=n)&&(y+1!=x))  add(x);
			y=x;
		}
	B[1]=1;
	for (int i=1; i<=mx; i++)
		{
			if (!B[i])  p[++m]=i;
			for (int j=1; j<=m&&i*p[j]<=mx; j++)
				{
					B[i*p[j]]=1;
					if (i%p[j]==0)  break;
				}
		}
	for (int i=1; i<=ma; i++)
		for (int j=1; j<=mb; j++)
			e[i][j]=!B[abs(a[i]-b[j])];
	for (int i=1; i<=ma; i++)  if (vis[0]++,dfs(i))  ans++;
	ans+=(ma-ans)/2*2+(mb-ans)/2*2+((ma-ans)&1)*3;
	printf("%d",ans);
}

int main()
{
	work();
	return 0;
}

### Prompt

Generate a CPP solution to the following problem:

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.

Examples

Input

2
4 5


Output

2


Input

9
1 2 3 4 5 6 7 8 9


Output

3


Input

2
1 10000000


Output

4

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;

const int N=205,MX=10000010;
int n,m,mx,ma,mb,a[N],b[N],e[N][N],vis[N],lmat[N],rmat[N],B[MX],p[MX/10],ans;

void add(int x){if (x&1)  a[++ma]=x;  else  b[++mb]=x;}

bool dfs(int x)
{
	for (int y=1; y<=mb; y++)
		if ((e[x][y])&&(vis[y]!=vis[0]))
			{
				vis[y]=vis[0];
				if ((!rmat[y])||(dfs(rmat[y])))  return lmat[x]=y,rmat[y]=x,1;
			}
	return 0;
}

void work()
{
	scanf("%d",&n);
	for (int i=1,x,y=-1; i<=n+1; i++)
		{
			if (i<=n)  scanf("%d",&x),mx=max(mx,x+1);
			if ((i!=1)&&(y+1!=x))  add(y+1);
			if ((i<=n)&&(y+1!=x))  add(x);
			y=x;
		}
	B[1]=1;
	for (int i=1; i<=mx; i++)
		{
			if (!B[i])  p[++m]=i;
			for (int j=1; j<=m&&i*p[j]<=mx; j++)
				{
					B[i*p[j]]=1;
					if (i%p[j]==0)  break;
				}
		}
	for (int i=1; i<=ma; i++)
		for (int j=1; j<=mb; j++)
			e[i][j]=!B[abs(a[i]-b[j])];
	for (int i=1; i<=ma; i++)  if (vis[0]++,dfs(i))  ans++;
	ans+=(ma-ans)/2*2+(mb-ans)/2*2+((ma-ans)&1)*3;
	printf("%d",ans);
}

int main()
{
	work();
	return 0;
}

```