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;
using pi3 = pair<pair<int, int>, int>;
const int NN = 300030;
const int mod[3] = {998244353, 1000000007, 1000000009};
int f[NN], p[NN], cnt[NN], val[NN];
int fac[3][NN], rev[3][NN], mu[NN];
int power(int a, int b, int c, int ans = 1) {
  for (; b; b >>= 1, a = (long long)a * a % c)
    if (b & 1) ans = (long long)ans * a % c;
  return ans;
}
int calc2(int n, int k, int i) {
  return (long long)fac[i][n] * rev[i][k] % mod[i] * rev[i][n - k] % mod[i];
}
pi3 calc1(int n, int k) {
  if (n < k) return pi3(pair<int, int>(0, 0), 0);
  return pi3(pair<int, int>(calc2(n, k, 0), calc2(n, k, 1)), calc2(n, k, 2));
}
pi3 operator-(const pi3 &a, const pi3 &b) {
  return pi3(
      pair<int, int>((a.first.first + mod[0] - b.first.first) % mod[0],
                     (a.first.second + mod[1] - b.first.second) % mod[1]),
      (a.second + mod[2] - b.second) % mod[2]);
}
pi3 operator+(const pi3 &a, const pi3 &b) {
  return pi3(pair<int, int>((a.first.first + b.first.first) % mod[0],
                            (a.first.second + b.first.second) % mod[1]),
             (a.second + b.second) % mod[2]);
}
int calc(int n, int k) {
  pi3 ans = calc1(n, k);
  for (int i = 2; i < NN; i++)
    if (mu[i] && cnt[i]) {
      if (mu[i] == -1)
        ans = ans - calc1(cnt[i], k);
      else
        ans = ans + calc1(cnt[i], k);
    }
  return ans.first.first || ans.first.second || ans.second;
}
int main() {
  for (int i = 0; i < 3; i++) {
    for (int j = fac[i][0] = 1; j < NN; j++)
      fac[i][j] = (long long)fac[i][j - 1] * j % mod[i];
    rev[i][NN - 1] = power(fac[i][NN - 1], mod[i] - 2, mod[i]);
    for (int j = NN - 2; j >= 0; j--)
      rev[i][j] = (long long)rev[i][j + 1] * (j + 1) % mod[i];
  }
  int n, np = 0;
  mu[1] = 1;
  for (int i = 2; i < NN; i++) {
    if (!f[i]) f[i] = i, p[np++] = i;
    for (int j = 0; j < np && p[j] <= f[i] && p[j] * i < NN; j++)
      f[p[j] * i] = p[j];
    int u = i / f[i];
    if (f[u] != f[i]) mu[i] = -mu[u];
  }
  cin >> n;
  for (int i = 0, u; i < n; i++) {
    scanf("%d", &u);
    vector<int> a;
    while (u > 1) {
      int v = f[u];
      while (f[u] == v) u /= v;
      a.push_back(v);
    }
    cnt[1]++;
    val[0] = 1;
    for (int j = 1; j < 1 << a.size(); j++) {
      val[j] = val[j ^ (j & -j)] * a[__builtin_ctz(j)];
      cnt[val[j]]++;
    }
  }
  for (int i = 2; i < NN; i++)
    if (cnt[i] == n) return puts("-1");
  int st = 0, ed = n;
  while (st + 1 < ed) {
    int md = st + ed >> 1;
    if (calc(n, md))
      ed = md;
    else
      st = md;
  }
  cout << ed << endl;
  return 0;
}