#include <bits/stdc++.h>
using namespace std;
long long M = 1000000007;
int __ = 1;
void show_(int x) { cerr << x << '\n'; }
void show_(double x) { cerr << x << '\n'; }
void show_(float x) { cerr << x << '\n'; }
void show_(long long x) { cerr << x << '\n'; }
void show_(char x) { cerr << x << '\n'; }
void show_(string x) { cerr << x << '\n'; }
void show_(bool x) { cerr << (x ? 'T' : 'F') << '\n'; }
void show_(vector<int> x) {
  cerr << "[ ";
  for (int i : x) cerr << i << ", ";
  cerr << "]\n";
}
void show_(vector<double> x) {
  cerr << "[ ";
  for (double i : x) cerr << i << ", ";
  cerr << "]\n";
}
void show_(vector<float> x) {
  cerr << "[ ";
  for (float i : x) cerr << i << ", ";
  cerr << "]\n";
}
void show_(vector<long long> x) {
  cerr << "[ ";
  for (long long i : x) cerr << i << ", ";
  cerr << "]\n";
}
void show_(vector<char> x) {
  cerr << "[ ";
  for (char i : x) cerr << i << ", ";
  cerr << "]\n";
}
void show_(vector<string> x) {
  cerr << "[ ";
  for (string i : x) cerr << i << ", ";
  cerr << "]\n";
}
void show_(vector<bool> x) {
  cerr << "[ ";
  for (bool i : x) cerr << i << ", ";
  cerr << "]\n";
}
void show_(vector<vector<int>> x) {
  cerr << '\n';
  for (vector<int> i : x) {
    cerr << "\t[ ";
    for (int j : i) cerr << j << ", ";
    cerr << "]\n";
  }
}
void show_(vector<vector<char>> x) {
  cerr << '\n';
  for (vector<char> i : x) {
    cerr << "\t[ ";
    for (char j : i) cerr << j << ", ";
    cerr << "]\n";
  }
}
void show_(vector<vector<float>> x) {
  cerr << '\n';
  for (vector<float> i : x) {
    cerr << "\t[ ";
    for (float j : i) cerr << j << ", ";
    cerr << "]\n";
  }
}
void show_(vector<vector<double>> x) {
  cerr << '\n';
  for (vector<double> i : x) {
    cerr << "\t[ ";
    for (double j : i) cerr << j << ", ";
    cerr << "]\n";
  }
}
void show_(vector<vector<long long>> x) {
  cerr << '\n';
  for (vector<long long> i : x) {
    cerr << "\t[ ";
    for (long long j : i) cerr << j << ", ";
    cerr << "]\n";
  }
}
void show_(vector<vector<string>> x) {
  cerr << '\n';
  for (vector<string> i : x) {
    cerr << "\t[ ";
    for (string j : i) cerr << j << ", ";
    cerr << "]\n";
  }
}
void show_(vector<vector<bool>> x) {
  cerr << '\n';
  for (vector<bool> i : x) {
    cerr << "\t[ ";
    for (bool j : i) cerr << (j ? 'T' : 'F') << ", ";
    cerr << "]\n";
  }
}
void fast() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
long long gcd(long long a, long long b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
vector<int> primes;
void fill_sieve(int n) {
  primes = vector<int>(n + 1, -1);
  for (long long i = 2; i < (int)primes.size(); i++) {
    if (-1 == primes[i]) {
      for (long long j = i * i; j < (int)(primes.size()); j += i)
        if (-1 == primes[j]) primes[j] = i;
      primes[i] = i;
    }
  }
}
int main() {
  fast();
  for (int _ = 1; _ <= __; _++) {
    int n;
    cin >> n;
    fill_sieve(15000000 + 1);
    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    long long g = 0;
    for (int i = 0; i < n; i++) g = gcd(g, a[i]);
    for (int i = 0; i < n; i++) a[i] /= g;
    map<int, int> facts;
    for (int i = 0; i < n; i++) {
      set<int> temp;
      while (1 != a[i]) {
        temp.insert(primes[a[i]]);
        a[i] /= primes[a[i]];
      }
      while (!temp.empty()) {
        facts[*temp.begin()]++;
        temp.erase(temp.begin());
      }
    }
    int ans = n;
    for (auto x : facts) {
      ans = min(ans, n - x.second);
    }
    if (ans == n) ans = -1;
    cout << ans << "\n";
  }
  return 0;
}
