#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 998244353;
vector<bool> IsPrime(15000010, true);
void sieve(long long n) {
  IsPrime[0] = 0;
  IsPrime[1] = 0;
  for (long long i = (2); i < (n + 1); i++) {
    if (IsPrime[i]) {
      long long k = 2;
      while (k * i <= n) {
        IsPrime[k * i] = 0;
        k++;
      }
    }
  }
}
long long gcd(long long a, long long b) {
  if (a > b) swap(a, b);
  if (a == 0) return b;
  return gcd(b % a, a);
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = (0); i < (n); i++) cin >> a[i];
  sort(a.begin(), a.end());
  if (a[0] == a[n - 1]) {
    cout << -1 << '\n';
    return 0;
  }
  long long x = a[n - 1];
  long long cnt = 0;
  for (long long i = (0); i < (n); i++) {
    if (a[i] == 1)
      cnt++;
    else {
      x = gcd(x, a[i]);
    }
  }
  if (cnt > 0 && x > 1) {
    cout << cnt << '\n';
    return 0;
  }
  vector<long long> b(15000001);
  vector<long long> c(15000001);
  for (long long i = (2); i < (15000001); i++) {
    if (b[i] > 0) continue;
    long long k = 1;
    while (k * i <= 15000001) {
      b[i * k] = i;
      k++;
    }
  }
  long long cn = 0;
  for (long long i = (0); i < (n); i++) {
    if (a[i] == 1 || a[i] == x) continue;
    a[i] /= x;
    while (a[i] != 1) {
      long long d = b[a[i]];
      c[d]++;
      while (a[i] % d == 0) {
        a[i] /= d;
      }
      cn = max(c[d], cn);
    }
  }
  cout << n - cn << '\n';
}
