#include <bits/stdc++.h>
using namespace std;
int num[4000];
vector<int> p;
int gcd(int a, int b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  for (int i = 2; i < 4000; i++) {
    if (num[i] == 0) {
      p.push_back(i);
      for (int j = i + i; j < 4000; j += i) {
        num[j] = 1;
      }
    }
  }
  int n;
  cin >> n;
  int ar[n];
  cin >> ar[0];
  int div = ar[0];
  for (int i = 1; i < n; i++) {
    cin >> ar[i];
    div = gcd(div, ar[i]);
  }
  for (int i = 0; i < n; i++) {
    ar[i] /= div;
  }
  int mx = 0;
  int sz = p.size();
  map<int, int> c;
  for (int j = 0; j < n; j++) {
    for (int i = 0; i < sz; i++) {
      if (ar[j] % p[i] == 0) {
        c[p[i]]++;
        mx = max(mx, c[p[i]]);
        while (ar[j] % p[i] == 0 && ar[j] > 1) {
          ar[j] /= p[i];
        }
      }
    }
  }
  for (int j = 0; j < n; j++) {
    if (ar[j] != 1) {
      c[ar[j]]++;
      mx = max(mx, c[ar[j]]);
    }
  }
  if (mx == 0) {
    cout << -1;
  } else {
    cout << n - mx;
  }
  cout << '\n';
  cout.flush();
}
