#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) {
  while (y != 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}
const int W = 15001000;
int fac[W];
void init(void) {
  for (int i = (int)(2); i < (int)(W); i++) {
    if (fac[i] != 0) continue;
    fac[i] = i;
    for (int j = 2 * i; j < W; j += i) {
      fac[j] = i;
    }
  }
}
const int inf = 1e8;
int main(void) {
  init();
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = (int)(0); i < (int)(n); i++) cin >> a[i];
  int g = 0;
  for (int i = (int)(0); i < (int)(n); i++) g = gcd(g, a[i]);
  for (int i = (int)(0); i < (int)(n); i++) a[i] /= g;
  map<int, int> occur;
  for (int i = (int)(0); i < (int)(n); i++) {
    int v = a[i];
    while (v != 1) {
      int p = fac[v];
      occur[p] += 1;
      while (v % p == 0) {
        v /= p;
      }
    }
  }
  int mi = inf;
  for (pair<int, int> e : occur) {
    mi = min(mi, n - e.second);
  }
  if (mi >= inf) {
    cout << -1 << endl;
  } else {
    cout << mi << endl;
  }
}
