#include <bits/stdc++.h>
using namespace std;
int N, A[300100], U[15000100];
int gcd(int x, int y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  memset(U, -1, sizeof U);
  for (long long i = 2; i < 15000100; i++)
    if (U[i] == -1) {
      U[i] = i;
      for (long long m = i * i; m < 15000100; m += i) {
        U[m] = i;
      }
    }
  int g = A[0];
  for (int i = 0; i < N; i++) g = gcd(g, A[i]);
  for (int i = 0; i < N; i++) A[i] /= g;
  unordered_map<int, int> primes;
  for (int i = 0; i < N; i++) {
    int x = A[i];
    while (x > 1) {
      int d = U[x];
      primes[d]++;
      while (x % d == 0) x /= d;
    }
  }
  if (primes.size() == 0) {
    cout << -1 << endl;
    return 0;
  }
  int answer = N;
  for (auto &p : primes) {
    answer = min(answer, N - p.second);
  }
  cout << answer << endl;
  return 0;
}
