#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int D[8][300001], cnt[300001], mod_inv[10];
int fast_pow(long long a, long long b) {
  long long ret = 1;
  for (; b; b >>= 1) {
    if (b & 1) ret = (ret * a) % MOD;
    a = (a * a) % MOD;
  }
  return ret;
}
int nCr(int n, int r) {
  if (n < 0 || r < 0 || n < r) return 0;
  int ret = mod_inv[r];
  for (int i = 0; i < r; i++) {
    ret = (1LL * ret * (n - i)) % MOD;
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ((void)0);
  ((void)0);
  int N = 1;
  mod_inv[0] = 1;
  for (int i = 1; i < 10; i++) {
    mod_inv[i] = fast_pow(N *= i, MOD - 2);
  }
  for (cin >> N; N; N--) {
    int a;
    cin >> a;
    D[0][a]++;
  }
  for (int i = 1; i <= 300000; i++) {
    cnt[i] = D[0][i];
    for (int j = i + i; j <= 300000; j += i) {
      cnt[i] += D[0][j];
    }
  }
  for (int i = 1; i < 8; i++) {
    for (int j = 300000; j > 0; j--) {
      D[i][j] = nCr(cnt[j], i);
      for (int k = j + j; k <= 300000; k += j) {
        D[i][j] = (D[i][j] + MOD - D[i][k]) % MOD;
      }
    }
    if (D[i][1]) {
      cout << i << '\n';
      return 0;
    }
  }
  cout << "-1\n";
  return 0;
}
