#include <bits/stdc++.h>
using namespace std;
int const MAXN = 3e5 + 3;
long long sieve_size;
bitset<5005> bs;
vector<int> primes;
void sieve(long long size) {
  sieve_size = size + 1;
  bs.set();
  bs[0] = bs[1] = 0;
  for (long long i = 2; i <= sieve_size; i++)
    if (bs[i]) {
      for (long long j = i * i; j <= sieve_size; j += i) bs[j] = 0;
      primes.push_back((int)i);
    }
}
map<int, int> m;
int arr[MAXN];
void primeFactors(int N) {
  for (int i = 0; i < primes.size(); ++i) {
    int p = primes[i];
    if (N % p == 0) {
      while (N % p == 0) N /= p;
      m[p]++;
    }
  }
  if (N != 1) m[N]++;
}
int gcd(int a, int b) { return (b == 0 ? a : gcd(b, a % b)); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int g;
  cin >> g;
  arr[0] = g;
  for (int i = 1; i < n; ++i) {
    cin >> arr[i];
    g = gcd(arr[i], g);
  }
  for (int i = 0; i < n; ++i) arr[i] /= g;
  sieve(5000);
  for (int i = 0; i < n; ++i)
    if (arr[i] != 1) primeFactors(arr[i]);
  if (m.size() == 0) {
    cout << -1 << endl;
    return 0;
  }
  int maxi = 0;
  for (auto it = m.begin(); it != m.end(); ++it) maxi = max(maxi, it->second);
  cout << (n - maxi) << endl;
}
