#include <bits/stdc++.h>
using namespace std;
vector<int> p;
void init(int n) {
  p.assign(n + 1, -1);
  for (int i = 2; i <= n; i++) {
    if (p[i] != -1) continue;
    for (int j = 1; (i * j) <= n; j++) {
      if (p[i * j] == -1) p[i * j] = i;
    }
  }
}
int main() {
  init(15000001);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, a;
  cin >> n;
  vector<int> v;
  map<int, int> m;
  for (int i = 0; i < n; i++) {
    cin >> a;
    v.clear();
    while (a > 1) {
      v.push_back(p[a]);
      a /= p[a];
    }
    int aux = 1;
    if (!v.empty()) {
      m[v[0]]++;
      aux = v[0];
    }
    for (int i = 1; i < v.size(); i++) {
      if (v[i] != v[i - 1]) aux = 1;
      aux *= v[i];
      m[aux]++;
    }
  }
  int ma = -1;
  for (map<int, int>::iterator it = m.begin(); it != m.end(); it++) {
    if (it->second != n) ma = max(ma, it->second);
  }
  if (ma == -1)
    cout << -1;
  else
    cout << n - ma;
  return 0;
}
