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;
long long POW(long long A, long long N, long long MOD) {
  if (N == 0) return 1 % MOD;
  if (N == 1) return A % MOD;
  long long tmp = POW(A, N / 2, MOD) % MOD;
  if (N % 2)
    return ((tmp * tmp) % MOD * A % MOD) % MOD;
  else
    return (tmp * tmp) % MOD;
}
long long MUL(long long A, long long B, long long MOD) {
  long long r = 0;
  while (B) {
    r = (r + (A * (B % 2) % MOD)) % MOD;
    A = (A + A) % MOD;
    B /= 2;
  }
  return r;
}
long long GCD(long long A, long long B) { return B == 0 ? A : GCD(B, A % B); }
int dx[] = {0, -1, 0, 1, 0};
int dy[] = {0, 0, 1, 0, -1};
template <class X, class Y>
bool minimize(X &x, const Y &y) {
  X eps = 1e-9;
  if (x > y + eps) {
    x = y;
    return true;
  } else
    return false;
}
template <class X, class Y>
bool maximize(X &x, const Y &y) {
  X eps = 1e-9;
  if (x + eps < y) {
    x = y;
    return true;
  } else
    return false;
}
template <class T>
T Abs(const T &x) {
  return (x < 0 ? -x : x);
}
const int MAXN = 3e5 + 105;
const int MOD = 1e9 + 7;
int N;
int A[MAXN];
struct Ckn {
  static const int MAXN = 3e5 + 1000;
  long long fac[MAXN + 1000], ifac[MAXN + 1000];
  long long POW(long long A, long long N) {
    if (N == 0) return 1;
    if (N == 1) return A % MOD;
    long long tmp = POW(A, N / 2);
    if (N % 2)
      return (tmp * tmp % MOD * A) % MOD;
    else
      return (tmp * tmp) % MOD;
  }
  void PRE(int N) {
    fac[0] = 1;
    for (int i = 1; i <= N; ++i) fac[i] = (1ll * i * fac[i - 1]) % MOD;
    ifac[N - 1] = POW(fac[N - 1], MOD - 2);
    for (int i = N - 2; i >= 0; --i)
      ifac[i] = (1ll * (i + 1) * ifac[i + 1]) % MOD;
  }
  long long CALC(long long r, long long n) {
    if (n < r) return 0;
    return fac[n] * ifac[r] % MOD * ifac[n - r] % MOD;
  }
} Ckn;
int cnt[MAXN];
int dp[12][MAXN];
void Sub(int &a, const int &b) {
  a -= b;
  if (a < 0) a += MOD;
  if (a >= MOD) a -= MOD;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> N;
  for (int i = (1), _b = (N); i <= _b; ++i) {
    cin >> A[i];
    cnt[A[i]]++;
  }
  Ckn.PRE(300005);
  for (int i = (1), _b = (300000); i <= _b; ++i) {
    for (int j = 2 * i; j <= 300000; j += i) {
      cnt[i] += cnt[j];
    }
  }
  for (int i = (1), _b = (10); i <= _b; ++i) {
    for (int j = (300000), _a = (1); j >= _a; --j) {
      dp[i][j] = Ckn.CALC(i, cnt[j]);
      for (int k = 2 * j; k <= 300000; k += j) Sub(dp[i][j], dp[i][k]);
    }
    if (dp[i][1] > 0) {
      cout << i << '\n';
      exit(0);
    }
  }
  cout << -1;
  return 0;
}