#include<bits/stdc++.h>
using namespace std;
const int N = 15;
int n;
int p[N];
int res = N;
int group[N][N];
bool st[N];
int gcd(int x, int y) {
	return y ? gcd(y, x%y): x;
}
bool check(int group[],int gc, int x) {
	for (int i = 0; i < gc; i++)
		if (gcd(group[i], x) > 1)return false;
	return true;
}
void dfs(int g, int gc, int tc, int start) {
	if (g >= res)return;
	if (tc == n)res = g;
	bool flag = 1;
	for (int i = start; i < n; i++) {
		if (!st[i] && check(group[g],gc, i)) {
			group[g][gc] = i;
			st[i] = true;
			flag = false;
			dfs(g, gc + 1, tc + 1, i + 1);
			st[i] = false;
		}
	}
	if (flag)dfs(g + 1, 0, tc, 0);
}
int main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> p[i];
	dfs(1, 0, 0, 0);
	cout << res;
}