#include <bits/stdc++.h>
using namespace std;
inline int mod(int n, int m) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}
int gcd(int a, int b) { return (b == 0 ? a : gcd(b, a % b)); }
int exp(int a, int b, int m) {
  if (b == 0) return 1;
  if (b == 1) return mod(a, m);
  int 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);
}
const int N = 15000000;
vector<int> lp(N + 1);
vector<int> pr;
vector<int> vis(N + 1);
vector<int> ans;
void factor(int x) {
  if (x == 1) return;
  vis[lp[x]]++;
  ans.push_back(lp[x]);
  int k = lp[x];
  x /= lp[x];
  while (x != 1) {
    if (ans.back() != lp[x]) {
      vis[lp[x]]++;
    }
    k *= lp[x];
    vis[k]++;
    ans.push_back(k);
    ans.push_back(lp[x]);
    x /= lp[x];
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  for (int i = 2; i <= N; ++i) {
    if (lp[i] == 0) {
      lp[i] = i;
      pr.push_back(i);
    }
    for (int j = 0; j < (int)pr.size() && pr[j] <= lp[i] && i * pr[j] <= N; ++j)
      lp[i * pr[j]] = pr[j];
  }
  int n, a, b;
  cin >> n >> a >> b;
  factor(a);
  factor(b);
  int atual = gcd(a, b);
  for (int i = 2; i < n; i++) {
    int x;
    cin >> x;
    factor(x);
    atual = gcd(atual, x);
  }
  int fat = -1, melhor = -1;
  for (int i = 0; i < ans.size(); i++) {
    int qnt = vis[ans[i]];
    if (ans[i] > atual && vis[ans[i]] > melhor) {
      fat = ans[i];
      melhor = vis[ans[i]];
    }
  }
  if (fat <= atual) {
    cout << -1 << "\n";
  } else {
    cout << n - melhor << "\n";
  }
}
