#include <bits/stdc++.h>
using namespace std;
vector<int> primes;
vector<bool> pr;
int n, ans = 0;
void getprimes() {
  pr.resize(300000 + 1, true);
  pr[0] = pr[1] = false;
  for (int i = 2; i <= 300000 / 2; i++) {
    if (pr[i]) {
      primes.push_back(i);
      for (int j = i + i; j <= 300000; j += i) {
        pr[j] = false;
      }
    }
  }
  for (int i = 300000 / 2 + 1; i <= 300000; i++) {
    if (pr[i]) primes.push_back(i);
  }
}
map<int, map<int, int> > facs;
void factor(int m) {
  for (int i = 0; primes[i] * primes[i] <= m; i++) {
    int x = primes[i];
    if (m % x == 0) {
      for (int i = 1; m % x == 0; i++) {
        m /= x;
        facs[x][i]++;
      }
    }
  }
  if (m > 1) {
    facs[m][1]++;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  getprimes();
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i], factor(a[i]);
  for (auto& p : facs) {
    for (auto& x : p.second) {
      if (x.second != n) ans = max(ans, x.second);
    }
  }
  ans = ans ? n - ans : -1;
  cout << ans << endl;
  return 0;
}
