#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int N,M;
const int MAX_N = 111;
int a[MAX_N],b[MAX_N*2],sz;
vector<int> odd,even;

vector<int> path[MAX_N*2];
bool visit[MAX_N*2];
int match[MAX_N*2];

bool dfs(int x){
	if(visit[x])return false;
	visit[x]=1;
	for(int i=0;i<path[x].size();i++){
		int y=path[x][i];
		if(match[y]<0){
			match[y]=x;
			return true;
		}else if(dfs(match[y])){
			match[y]=x;
			return true;
		}
	}
	return false;
}

bool isPrime(int x){
	if(x==1)return false;
	if(x%2==0)return false; // 2 is exception
	for(int i=3;i*i<=x;i+=2){
		if(x%i==0)return false;
	}
	return true;
}

int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",&a[i]);
	}

	b[sz++]=a[0];
	for(int i=1;i<N;i++){
		if(a[i-1]+1<a[i]){
			b[sz++]=a[i-1]+1;
			b[sz++]=a[i];
		}
	}
	b[sz++]=a[N-1]+1;

	for(int i=0;i<sz;i++){
		if(b[i]%2==0)even.push_back(b[i]);
		else odd.push_back(b[i]);
	}

	for(int i=0;i<even.size();i++){
		for(int j=0;j<odd.size();j++){
			if(isPrime(abs(even[i]-odd[j]))){
				path[i].push_back(j);
			}
		}
	}

	for(int i=0;i<odd.size();i++){
		match[i]=-1;
	}
	
	int cnt=0;
	for(int i=0;i<even.size();i++){
		for(int j=0;j<even.size();j++)visit[j]=0;
		if(dfs(i))cnt++;
	}

	int z0=even.size()-cnt;
	int z1=odd.size()-cnt;
	printf("%d\n",cnt+(z0/2+z1/2)*2+(z0%2)*3);

	return 0;
}

### Prompt

Create a solution in cpp for 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 <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int N,M;
const int MAX_N = 111;
int a[MAX_N],b[MAX_N*2],sz;
vector<int> odd,even;

vector<int> path[MAX_N*2];
bool visit[MAX_N*2];
int match[MAX_N*2];

bool dfs(int x){
	if(visit[x])return false;
	visit[x]=1;
	for(int i=0;i<path[x].size();i++){
		int y=path[x][i];
		if(match[y]<0){
			match[y]=x;
			return true;
		}else if(dfs(match[y])){
			match[y]=x;
			return true;
		}
	}
	return false;
}

bool isPrime(int x){
	if(x==1)return false;
	if(x%2==0)return false; // 2 is exception
	for(int i=3;i*i<=x;i+=2){
		if(x%i==0)return false;
	}
	return true;
}

int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",&a[i]);
	}

	b[sz++]=a[0];
	for(int i=1;i<N;i++){
		if(a[i-1]+1<a[i]){
			b[sz++]=a[i-1]+1;
			b[sz++]=a[i];
		}
	}
	b[sz++]=a[N-1]+1;

	for(int i=0;i<sz;i++){
		if(b[i]%2==0)even.push_back(b[i]);
		else odd.push_back(b[i]);
	}

	for(int i=0;i<even.size();i++){
		for(int j=0;j<odd.size();j++){
			if(isPrime(abs(even[i]-odd[j]))){
				path[i].push_back(j);
			}
		}
	}

	for(int i=0;i<odd.size();i++){
		match[i]=-1;
	}
	
	int cnt=0;
	for(int i=0;i<even.size();i++){
		for(int j=0;j<even.size();j++)visit[j]=0;
		if(dfs(i))cnt++;
	}

	int z0=even.size()-cnt;
	int z1=odd.size()-cnt;
	printf("%d\n",cnt+(z0/2+z1/2)*2+(z0%2)*3);

	return 0;
}

```