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;
const int MXN = 4e5 + 6;
const int INF = 0x3f3f3f3f;
struct fastio {
  char s[100005];
  int it, len;
  fastio() { it = len = 0; }
  inline char get() {
    if (it < len) return s[it++];
    it = 0;
    len = fread(s, 1, 100000, stdin);
    if (len == 0)
      return EOF;
    else
      return s[it++];
  }
  bool notend() {
    char c = get();
    while (c == ' ' || c == '\n') c = get();
    if (it > 0) it--;
    return c != EOF;
  }
} _buff;
inline long long getnum() {
  long long r = 0;
  bool ng = 0;
  char c;
  c = _buff.get();
  while (c != '-' && (c < '0' || c > '9')) c = _buff.get();
  if (c == '-') ng = 1, c = _buff.get();
  while (c >= '0' && c <= '9') r = r * 10 + c - '0', c = _buff.get();
  return ng ? -r : r;
}
template <class T>
inline void putnum(T x) {
  if (x < 0) putchar('-'), x = -x;
  register short a[20] = {}, sz = 0;
  while (x) a[sz++] = x % 10, x /= 10;
  if (sz == 0) putchar('0');
  for (int i = sz - 1; i >= 0; i--) putchar('0' + a[i]);
}
inline char getreal() {
  char c = _buff.get();
  while (c <= 32) c = _buff.get();
  return c;
}
const int mod[2] = {(int)1e9 + 7, (int)1e9 + 9};
int n, m;
int ar[MXN], sum[MXN];
long long tmp[MXN], f[MXN], inv[2][MXN];
;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
bool ok(int s) {
  for (int o = 0; o < 2; ++o) {
    for (int i = 0; i < s; ++i) f[i] = 0;
    long long cf = 1;
    for (int i = s; i <= n; ++i) {
      f[i] = cf;
      cf = cf * (i + 1) % mod[o] * inv[o][i + 1 - s] % mod[o];
    }
    for (int i = m; i >= 1; --i) {
      tmp[i] = f[sum[i]];
      for (int j = i + i; j <= m; j += i) {
        tmp[i] -= tmp[j];
        if (tmp[i] < 0) tmp[i] = (tmp[i] + mod[o]) % mod[o];
      }
    }
    if (tmp[1]) return 1;
  }
  return 0;
}
int main() {
  for (int o = 0; o < 2; ++o) {
    long long p = mod[o];
    inv[o][1] = 1;
    for (int i = 2; i < MXN; ++i) inv[o][i] = (p - p / i) * inv[o][p % i] % p;
  }
  n = getnum();
  int p = 0;
  m = 0;
  for (int i = 1; i <= n; ++i) {
    ar[i] = getnum();
    m = m > ar[i] ? m : ar[i];
    p = gcd(p, ar[i]);
    ++sum[ar[i]];
  }
  if (p != 1) {
    putnum(-1), putchar('\n');
    return 0;
  }
  for (int i = 1; i <= m; ++i) {
    for (int j = i << 1; j <= m; j += i) {
      sum[i] += sum[j];
    }
  }
  int ans = 1, L = 1, R = min(n, 7), mid;
  while (R >= L) {
    mid = (L + R) >> 1;
    if (ok(mid))
      ans = mid, R = mid - 1;
    else
      L = mid + 1;
  }
  putnum(ans), putchar('\n');
  return 0;
}