#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const double EPS = 1e-7;
const int INF = numeric_limits<int>::max();
void fast_io() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
}
const int N = 1.5e7 + 10;
int gcd(int a, int b) {
  if (a > b) swap(a, b);
  if (a == 0) return b;
  return gcd(b % a, a);
}
vector<int> primes;
bool sieve[N];
int freq[N];
void solve_test() {
  for (int i = 2; i < (N); ++i) {
    if (sieve[i]) continue;
    primes.push_back(i);
    for (int j = i; j < N; j += i) {
      sieve[j] = 1;
    }
  }
  int n;
  cin >> n;
  vector<int> a(n);
  int m = 0;
  for (auto& i : (a)) {
    cin >> i;
    m = gcd(m, i);
    freq[i]++;
  }
  int best = 0;
  for (int i = 0; i < (int)(primes).size() && primes[i] * m < N; ++i) {
    int c = 0, cur = primes[i] * m;
    for (int j = cur; j < N; j += cur) {
      c += freq[j];
    }
    best = max(best, c);
  }
  if (best == 0)
    cout << "-1\n";
  else
    cout << n - best << "\n";
}
int main() {
  srand(time(0));
  int t = 1;
  while (t--) {
    solve_test();
  }
}
