#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int gcdvec(vector<long long int>& n) {
  int gcdd = n[0];
  for (int i = 0; i < n.size(); i++) {
    gcdd = gcd(n[i], gcdd);
  }
  return gcdd;
}
int main() {
  std::vector<int> sieve(15000005);
  vector<int> prime_div_count(15000005);
  vector<long long int> primes, numbers;
  for (long long int i = 0; i < 15000005; i++) {
    sieve[i] = 0;
    prime_div_count[i] = 0;
  }
  for (long long int i = 2; i < 15000005; i++) {
    if (sieve[i]) continue;
    for (int j = i; j < 15000005; j += i) {
      sieve[j] = i;
    }
  }
  int N;
  cin >> N;
  long long int maxs = 0, gd = 0;
  for (long long int i = 0; i < N; i++) {
    long long int cN;
    cin >> cN;
    numbers.push_back(cN);
    if (gd == 0)
      gd = cN;
    else
      gd = gcd(gd, cN);
    if (maxs <= cN) {
      maxs = cN;
    }
  }
  long long int max1 = 0, mE1 = 0, max2 = 0, mE2 = 0;
  for (long long int i = 0; i < N; i++) {
    for (int j = numbers[i] / gd; j > 1;) {
      int x = sieve[j];
      prime_div_count[sieve[j]]++;
      while (sieve[j] == x) {
        j /= x;
      }
    }
  }
  for (int i = 0; i < 15000005; i++)
    max2 = max((long long int)prime_div_count[i], max2);
  if (max1 == max2 || max2 == 0)
    cout << -1 << endl;
  else
    cout << N - max2 << endl;
  return 0;
}
