Problem: Janusz is a businessman. He owns a company "Januszex", which produces games for teenagers. Last hit of Januszex was a cool one-person game "Make it one". The player is given a sequence of n integers a_i.

It is allowed to select any subset of them, and the score is equal to the greatest common divisor of selected elements. The goal is to take as little elements as it is possible, getting the score 1. Now Janusz wonders, for given sequence, how much elements should the player choose?

Input

The first line contains an only integer n (1 ≤ n ≤ 300 000) — the number of integers in the sequence.

The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 300 000).

Output

If there is no subset of the given sequence with gcd equal to 1, output -1.

Otherwise, output exactly one integer — the size of the smallest subset with gcd equal to 1.

Examples

Input

3
10 6 15


Output

3


Input

3
2 4 6


Output

-1


Input

7
30 60 21 42 70 15 30


Output

3

Note

In the first example, selecting a subset of all numbers gives a gcd of 1 and for all smaller subsets the gcd is greater than 1.

In the second example, for all subsets of numbers the gcd is at least 2. 

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
const long long int MAXN = 3e5 + 15, md = 2000000357, inf = 1e15;
long long int tav(long long int n, long long int k) {
  long long int res = 1;
  while (k > 0) {
    if (k & 1) {
      res *= n;
      res %= md;
    }
    n *= n;
    n %= md;
    k /= 2;
  }
  return res;
}
long long int fact[MAXN], fact_md[MAXN];
void fact_build() {
  fact[0] = 1;
  fact_md[0] = 1;
  for (int i = 1; i < MAXN; i++) {
    fact[i] = fact[i - 1] * i;
    fact[i] %= md;
    fact_md[i] = tav(fact[i], md - 2);
  }
}
long long int chs(long long int n, long long int k) {
  if (k > n || k < 0) return 0;
  return (((fact[n] * fact_md[k]) % md) * fact_md[n - k]) % md;
}
vector<long long int> sf, pr[MAXN], d[MAXN];
long long int sfs;
bitset<MAXN> gh, sq;
void prime() {
  gh.set();
  gh[0] = false;
  gh[1] = false;
  sq.set();
  sq[0] = false;
  sf.push_back(1);
  for (long long int i = 2; i < MAXN; i++) {
    if (gh[i]) {
      pr[i].push_back(i);
      for (long long int j = 2 * i; j < MAXN; j += i) {
        pr[j].push_back(i);
        gh[j] = false;
      }
      long long int h = i * i;
      for (long long int j = h; j < MAXN; j += h) sq[j] = false;
    }
    if (sq[i]) {
      sf.push_back(i);
    }
  }
  sfs = sf.size();
  return;
}
long long int n, a[MAXN], dp[MAXN], z[MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  memset(dp, 0, sizeof(dp));
  fact_build();
  prime();
  for (auto i : sf) {
    long long int ps = pr[i].size(), lm = 1 << ps;
    for (long long int j = 0; j < lm; j++) {
      long long int o = 1, res = 1;
      for (long long int q = 0; q < ps; q++) {
        if (o & j) {
          res *= pr[i][q];
        }
        o <<= 1;
      }
      d[i].push_back(res);
    }
  }
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 1) {
      cout << "1\n";
      return 0;
    }
    for (auto j : pr[a[i]]) {
      long long int h = j * j;
      while (a[i] % h == 0) a[i] /= j;
    }
    for (auto j : d[a[i]]) {
      z[j]++;
    }
  }
  for (long long int k = 2; k <= 7; k++) {
    for (auto i : sf) {
      dp[i] = chs(z[i], k);
    }
    for (long long int e = sfs - 1; e >= 0; e--) {
      long long int i = sf[e];
      for (long long int w = 1; w < sfs; w++) {
        long long int j = sf[w];
        if (i * j >= MAXN) break;
        if (!sq[i * j]) continue;
        dp[i] -= dp[i * j] - md;
        dp[i] %= md;
      }
    }
    if (dp[1] >= 1) {
      cout << k << '\n';
      return 0;
    }
  }
  cout << "-1\n";
  return 0;
}