#include <bits/stdc++.h>

using namespace std;

bool notP[10000005];

int prime[1000005], tot = 0;

void getPrime() {
    int n = 10000000;
    for (int i = 2; i <= n; ++i) {
        if (!notP[i])
            prime[tot++] = i;
        for (int j = 0; j < tot && i * prime[j] <= n; ++j) {
            notP[i * prime[j]] = true;
            if (i % prime[j] == 0)
                break;
        }
    }
}

vector <int> A[2];

vector <int> G[105];

int mat[105], used[105], tag = 0;

int dfs(int u) {
    for (auto v : G[u]) {
        if (used[v] == tag)
            continue;
        used[v] = tag;
        if (mat[v] == -1 || dfs(mat[v])) {
            mat[v] = u;
            return 1;
        }
    }
    return 0;
}

int main() {
    getPrime();
    int n, p = -1;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        if (p != x - 1) {
            if (p != -1)
                A[(p + 1) & 1].push_back(p + 1);
            A[x & 1].push_back(x);
        }
        p = x;
    }
    A[(p + 1) & 1].push_back(p + 1);
    for (int i = 0; i < (int)A[0].size(); ++i) {
        for (int j = 0; j < (int)A[1].size(); ++j) {
            int d = abs(A[0][i] - A[1][j]);
            if (d >= 3 && !notP[d])
                G[i].push_back(j);
        }
    }
    memset(mat, -1, sizeof(mat));
    int k = 0;
    for (int i = 0; i < (int)A[0].size(); ++i) {
        ++ tag;
        k += dfs(i);
    }
    int ans = k + (A[0].size() - k) / 2 * 2 + (A[1].size() - k) / 2 * 2;
    if ((A[0].size() - k) % 2)
        ans += 3;
    printf("%d\n", ans);
    return 0;
}

### Prompt

Develop a solution in cpp to the problem described below:

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;

bool notP[10000005];

int prime[1000005], tot = 0;

void getPrime() {
    int n = 10000000;
    for (int i = 2; i <= n; ++i) {
        if (!notP[i])
            prime[tot++] = i;
        for (int j = 0; j < tot && i * prime[j] <= n; ++j) {
            notP[i * prime[j]] = true;
            if (i % prime[j] == 0)
                break;
        }
    }
}

vector <int> A[2];

vector <int> G[105];

int mat[105], used[105], tag = 0;

int dfs(int u) {
    for (auto v : G[u]) {
        if (used[v] == tag)
            continue;
        used[v] = tag;
        if (mat[v] == -1 || dfs(mat[v])) {
            mat[v] = u;
            return 1;
        }
    }
    return 0;
}

int main() {
    getPrime();
    int n, p = -1;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        if (p != x - 1) {
            if (p != -1)
                A[(p + 1) & 1].push_back(p + 1);
            A[x & 1].push_back(x);
        }
        p = x;
    }
    A[(p + 1) & 1].push_back(p + 1);
    for (int i = 0; i < (int)A[0].size(); ++i) {
        for (int j = 0; j < (int)A[1].size(); ++j) {
            int d = abs(A[0][i] - A[1][j]);
            if (d >= 3 && !notP[d])
                G[i].push_back(j);
        }
    }
    memset(mat, -1, sizeof(mat));
    int k = 0;
    for (int i = 0; i < (int)A[0].size(); ++i) {
        ++ tag;
        k += dfs(i);
    }
    int ans = k + (A[0].size() - k) / 2 * 2 + (A[1].size() - k) / 2 * 2;
    if ((A[0].size() - k) % 2)
        ans += 3;
    printf("%d\n", ans);
    return 0;
}

```