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 S, class T>
pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) {
  return pair<S, T>(s.first + t.first, s.second + t.second);
}
template <class S, class T>
pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) {
  return pair<S, T>(s.first - t.first, s.second - t.second);
}
template <class S, class T>
ostream &operator<<(ostream &os, pair<S, T> p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long inf = 1000000001;
const long long INF = 1e18;
const long long MOD = 1000000007;
const double pi = 3.14159265358979323846;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1};
long long gcd(long long a, long long b) {
  if (b > a) {
    swap(a, b);
  }
  long long r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
const int MAXN = 301000;
long long mod_pow(long long x, long long p, long long M = MOD) {
  long long a = 1;
  while (p) {
    if (p % 2) a = a * x % M;
    x = x * x % M;
    p /= 2;
  }
  return a;
}
long long mod_inverse(long long a, long long M = MOD) {
  return mod_pow(a, M - 2, M);
}
void set_fact(long long n, vector<long long> &fact, vector<long long> &rfact,
              long long M = MOD) {
  fact[0] = fact[1] = rfact[0] = rfact[1] = 1;
  for (long long i = 2; i <= n; i++) {
    fact[i] = i * fact[i - 1] % M;
    rfact[i] = mod_inverse(fact[i], M);
  }
}
long long nCr(long long n, long long r, vector<long long> &fact,
              vector<long long> &rfact, long long M = MOD) {
  if (r > n) return 0;
  long long ret = fact[n];
  ret = (ret * rfact[r]) % M;
  ret = (ret * rfact[n - r]) % M;
  return ret;
}
const int MAX = 300010;
vector<long long> fact(MAX + 5), fact2(MAX + 5), rfact(MAX + 5),
    rfact2(MAX + 5);
vector<vector<long long> > dp(8, vector<long long>(MAX)),
    dp2(8, vector<long long>(MAX));
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ;
  int n;
  cin >> n;
  const long long MOD2 = 998244353;
  set_fact(MAX, fact, rfact, MOD);
  set_fact(MAX, fact2, rfact2, MOD2);
  vector<int> a(n);
  for (int i = 0; i < (n); i++) {
    cin >> a[i];
  }
  int g = a[0];
  for (int i = 1; i <= (n - 1); i++) {
    g = gcd(g, a[i]);
  }
  if (g != 1) {
    cout << -1 << endl;
    return 0;
  }
  vector<int> num(MAX);
  for (int i = 0; i < (n); i++) {
    num[a[i]]++;
  }
  for (int i = 1; i <= (MAX - 1); i++) {
    for (int j = 2; j * i < MAX; j++) {
      num[i] += num[j * i];
    }
  }
  int m = 8;
  for (int i = 1; i < m; i++) {
    for (int j = MAX - 1; j >= 1; j--) {
      dp[i][j] = nCr(num[j], i, fact, rfact, MOD);
      dp2[i][j] = nCr(num[j], i, fact2, rfact2, MOD2);
      for (int k = 2; j * k < MAX; k++) {
        dp[i][j] -= dp[i][j * k];
        dp[i][j] %= MOD;
        dp2[i][j] -= dp2[i][j * k];
        dp2[i][j] %= MOD2;
      }
    }
  }
  for (int i = 1; i <= (m - 1); i++) {
    if (dp[i][1] != 0 || dp2[i][1] != 0) {
      cout << i << endl;
      return 0;
    }
  }
}