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;
template <class T>
using VV = vector<vector<T>>;
template <class T>
inline T SMIN(T& a, const T b) {
  return a = (a > b) ? b : a;
}
template <class T>
inline T SMAX(T& a, const T b) {
  return a = (a < b) ? b : a;
}
template <class Iter>
void dumpc(Iter begin, Iter end) {
  if (true) {
    for (; begin != end; ++begin) {
      cerr << *begin << ',';
    }
    cerr << endl;
  }
}
const int MAX_N = 3e5 + 1;
int A[MAX_N];
int N;
const long long MOD = 1e9 + 7;
long long C[MAX_N][11];
long long dp[MAX_N];
int cnt[MAX_N];
void solve() {
  for (int i = 0; i < (MAX_N); ++i) {
    C[i][0] = 1;
    for (int j = (1); j <= (min(10, i)); ++j)
      C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
  }
  for (int i = 0; i < (N); ++i) cnt[A[i]]++;
  for (int n = (1); n < (MAX_N); ++n)
    for (int kn = 2 * n; kn < MAX_N; kn += n) cnt[n] += cnt[kn];
  for (int x = (1); x <= (8); ++x) {
    memset(dp, 0, sizeof(dp));
    for (int g = MAX_N - 1; g >= 1; --g) {
      dp[g] = C[cnt[g]][x];
      for (int kg = 2 * g; kg < MAX_N; kg += g) (dp[g] += MOD - dp[kg]) %= MOD;
    }
    if (dp[1] > 0) {
      cout << x << endl;
      exit(0);
    }
  }
  cout << -1 << endl;
}
vector<long long> distinctPrimeFactors(long long n) {
  assert(n >= 1);
  vector<long long> res;
  for (long long p = 2; p * p <= n; ++p)
    if (n % p == 0) {
      res.push_back(p);
      while (n % p == 0) n /= p;
    }
  if (n > 1) res.push_back(n);
  return res;
}
long long f[1 << 10];
void ztransform_subset(int N) {
  for (int i = 0; i < N; ++i) {
    for (int T = 0; T < (1 << N); ++T) {
      if ((T >> i) & 1) f[T] = min(f[T ^ (1 << i)] + f[1 << i], f[T]);
    }
  }
}
void solve_TLE() {
  const long long Inf = 1e7;
  long long res = Inf;
  for (int i = 0; i < (N); ++i) {
    vector<long long> P = distinctPrimeFactors(A[i]);
    int M = int((P).size());
    for (int mask = 0; mask < (1 << M); ++mask) f[mask] = Inf;
    for (int j = 0; j < (N); ++j)
      if (i != j) {
        int mask = 0;
        for (int k = 0; k < (M); ++k) {
          int p = (int)P[k];
          if (A[j] % p != 0) {
            mask |= 1 << k;
            f[1 << k] = 1;
          }
        }
        SMIN(f[mask], 1LL);
      }
    ztransform_subset(M);
    int full = (1 << M) - 1;
    SMIN(res, f[full] + 1);
  }
  if (res >= Inf) res = -1;
  cout << res << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  scanf("%d", &N);
  for (int i = 0; i < (N); ++i) {
    scanf("%d", &A[i]);
    if (A[i] == 1) {
      cout << 1 << endl;
      exit(0);
    }
  }
  solve();
  return 0;
}