#include <bits/stdc++.h>
using namespace std;
vector<int> mpn(15000005);
vector<int> pn;
vector<int> divisors(15000005);
int main() {
  for (int i = 2; i < 15000005; i++) {
    if (mpn[i] == 0) {
      mpn[i] = i;
      pn.push_back(i);
    }
    for (int j = 0; j < pn.size() && pn[j] <= mpn[i] && i * pn[j] < 15000005;
         j++) {
      mpn[i * pn[j]] = pn[j];
    }
  }
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    int prev_divisor = 0;
    while (a > 1) {
      int min_divisor = mpn[a];
      if (a != min_divisor) {
        divisors[a]++;
      }
      if (min_divisor != prev_divisor) {
        divisors[min_divisor]++;
      }
      a /= min_divisor;
      prev_divisor = min_divisor;
    }
  }
  int res = 0;
  for (int i = 2; i < 15000005; i++) {
    if (divisors[i] < n) {
      res = max(res, divisors[i]);
    }
  }
  cout << (res == 0 ? -1 : n - res) << endl;
  return 0;
}
