#include <bits/stdc++.h>
using namespace std;
const int N = 15e6;
vector<int> pr;
int lp[N + 1], kl[N + 1];
void sieve() {
  for (int i = 2; i <= N; i++) {
    if (!lp[i]) {
      lp[i] = i;
      pr.push_back(i);
    }
    for (int j = 0; j < pr.size() && pr[j] <= lp[i] && pr[j] * i <= N; j++)
      lp[pr[j] * i] = pr[j];
  }
}
int gcd(int a, int b) {
  while (a != 0 && b != 0)
    if (a > b)
      a %= b;
    else
      b %= a;
  return a + b;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a[0] >> a[1];
  int g = gcd(a[0], a[1]);
  for (int i = 2; i < n; i++) {
    cin >> a[i];
    g = gcd(g, a[i]);
  }
  for (int i = 0; i < n; i++) a[i] /= g;
  sieve();
  for (int i = 0; i < n; i++) {
    int j = a[i];
    while (j > 1) {
      int z = lp[j];
      kl[z]++;
      while (j % z == 0) j /= z;
    }
  }
  int mx = 0;
  for (int i = 2; i <= N; i++) mx = max(mx, kl[i]);
  if (!mx)
    cout << -1;
  else
    cout << n - mx;
}
