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;
inline long long mod(long long n, long long m) {
  long long ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
long long exp(long long a, long long b, long long m) {
  if (b == 0) return 1;
  if (b == 1) return mod(a, m);
  long long k = mod(exp(a, b / 2, m), m);
  if (b & 1) {
    return mod(a * mod(k * k, m), m);
  } else
    return mod(k * k, m);
}
struct query {
  long long l, r, x, id;
};
long long ans[300100];
long long cnt[300100];
vector<long long> d[300100];
long long mark[300100];
long long mu[300100];
long long a[300100];
void crivo() {
  mu[1] = 1;
  vector<long long> primes;
  for (long long i = 2; i < 300100; i++) {
    if (!mark[i]) {
      primes.push_back(i);
      mu[i] = -1;
    }
    for (long long j = 0; j < primes.size() && primes[j] * i < 300100; j++) {
      mark[i * primes[j]] = true;
      if (i % primes[j] == 0) {
        mu[i * primes[j]] = 0;
        break;
      } else {
        mu[i * primes[j]] = -mu[i];
      }
    }
  }
  for (long long i = 1; i < 300100; i++) {
    for (long long j = i; j < 300100; j += i) {
      d[j].push_back(i);
    }
  }
}
void update(long long x, long long v) {
  for (long long i = 0; i < d[x].size(); i++) {
    cnt[d[x][i]] += v;
  }
}
long long coprime(long long x, long long L, long long R) {
  long long r = 0;
  for (long long i = 0; i < d[x].size(); i++) {
    r += cnt[d[x][i]] * mu[d[x][i]];
  }
  return r;
}
long long fat[300100];
long long inv[300100];
long long fat2[300100];
long long inv2[300100];
const long long M = 1e9 + 7;
const long long MM = 1e9 + 9;
long long C(long long r, long long qtd) {
  if (r < qtd) return 0;
  return (fat[r] * inv[r - qtd]) % M;
}
long long C2(long long r, long long qtd) {
  if (r < qtd) return 0;
  return (fat2[r] * inv2[r - qtd]) % MM;
}
long long n;
const long long MAX = 300000;
long long ok(long long x) {
  long long r = 0;
  long long r2 = 0;
  for (long long i = 1; i <= MAX; i++) {
    r2 += mu[i] * C2(cnt[i], x);
    r2 %= MM;
  }
  for (long long i = 1; i <= MAX; i++) {
    r += mu[i] * C(cnt[i], x);
    r %= M;
  }
  return (r != 0) || (r2 != 0);
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  crivo();
  fat[0] = inv[0] = 1;
  fat2[0] = inv2[0] = 1;
  for (long long i = 1; i < 300100; i++) {
    fat[i] = (fat[i - 1] * i) % M;
    inv[i] = exp(fat[i], M - 2, M);
    fat2[i] = (fat2[i - 1] * i) % MM;
    inv2[i] = exp(fat2[i], MM - 2, MM);
  }
  long long g = -1;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    update(a[i], 1);
    if (g == -1)
      g = a[i];
    else
      g = gcd(g, a[i]);
  }
  if (g != 1) {
    cout << -1 << "\n";
    return 0;
  }
  long long l = 1, r = n;
  long long ans = n;
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (ok(mid)) {
      r = mid - 1;
      ans = mid;
    } else
      l = mid + 1;
  }
  cout << ans << "\n";
}