#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
const int N = 3e5;
const int mod = 1e9 + 7;
long long dp[maxn];
int fen[maxn], mu[maxn];
long long pow_mod(long long x, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}
void init() {
  fen[0] = 1;
  for (int i = 1; i <= N; ++i) fen[i] = 1ll * fen[i - 1] * i % mod;
  mu[N] = pow_mod(fen[N], mod - 2);
  for (int i = N; i >= 1; --i) {
    mu[i - 1] = 1ll * mu[i] * i % mod;
  }
}
int C(int a, int b) {
  if (b < 0 || a < b) return 0;
  return 1ll * fen[a] * mu[b] % mod * mu[a - b] % mod;
}
int cnt[maxn];
int main() {
  init();
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    cnt[x]++;
  }
  for (int i = 1; i <= N; ++i)
    for (int j = 2 * i; j <= N; j += i) {
      cnt[i] += cnt[j];
    }
  for (int i = 1; i <= 10; ++i) {
    for (int j = N; j >= 1; --j) {
      dp[j] = C(cnt[j], i);
      for (int k = j + j; k <= N; k += j) dp[j] = (dp[j] - dp[k] + mod) % mod;
    }
    if (dp[1] > 0) {
      printf("%d\n", i);
      exit(0);
    }
  }
  puts("-1");
  return 0;
}
