#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
int F[210][210], n, A[210], B[210], CA, CB, sink, v[210], cur = 1;
map<int,int>Map;
bool Prime(int a){
    if(a<0)a=-a;
    if(a==1)return false;
    int i;
    for(i=2;i*i<=a;i++)if(a%i==0)return false;
    return true;
}
int MaxFlow(int a){
    if(a==sink)return 1;
    v[a] = cur;
    int i;
    for(i=0;i<=sink;i++){
        if(F[a][i] && v[i]!=cur){
            if(MaxFlow(i)){
                F[a][i]--;
                F[i][a]++;
                return 1;
            }
        }
    }
    return 0;
}
int main(){
    int i, a, j, f = 0;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&a);
        Map[a]++;
        Map[a+1]++;
    }
    for(auto &p : Map){
        if(p.second%2 == 1){
            if(p.first%2 == 0) A[++CA] = p.first;
            else B[++CB] = p.first;
        }
    }
    sink = CA+CB+1;
    for(i=1;i<=CA;i++){
        for(j=1;j<=CB;j++){
            if(Prime(B[j]-A[i])){
                F[i][CA+j] = 1;
            }
        }
        F[0][i]=1;
    }
    for(i=CA+1;i<=CA+CB;i++)F[i][sink]=1;
    while(MaxFlow(0)){
        f++,cur++;
    }
    printf("%d\n", f + (CA-f)/2*2 + (CB-f)/2*2 + (CA-f)%2*3);
}