#include<bits/stdc++.h>
using namespace std;
const int N = 205, M = 1e7 + 8;

int n, x[N], prime[M], tot, k, own[N], m, y[N];
bool vis[M], use[N];
vector<int>S, T, V[N];

int find (int x) {
	for (auto v : V[x]) if (!use[v]) {
		use[v] = 1;
		if (!own[v] || find(own[v])) {
			own[v] = x;
			return 1;
		}
	}
	return 0;
}

int main () {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &y[i]);
	sort(y + 1, y + n + 1);
	x[m = 1] = y[1];
	if (y[1] + 1 != y[2]) x[++m] = y[1] + 1;
	for (int i = 2; i <= n; ++i) {
		if (y[i] != y[i - 1] + 1) x[++m] = y[i];
		if (y[i] != y[i + 1] - 1) x[++m] = y[i] + 1;
	}
	n = m;
	vis[1] = 1;
	for (int i = 2; i <= 1e7; ++i) {
		if (!vis[i]) prime[++tot] = i;
		for (int j = 1; j <= tot && i * prime[j] <= 1e7; ++j) {
			vis[i * prime[j]] = 1;
			if (i % prime[j] == 0) break;
		}
	}
	for (int i = 1; i <= n; ++i) if (x[i] & 1) S.emplace_back(i); else T.emplace_back(i);
	for (auto u : S) for (auto v : T) if (!vis[abs(x[u] - x[v])]) V[u].emplace_back(v);
	for (auto u : S) if (memset(use, 0, sizeof use), find(u)) ++k;
	printf("%d\n", (S.size() - k) / 2 * 2 + (T.size() - k) / 2 * 2 + ((S.size() - k) & 1) * 3 + k);
	return 0;
}