#include <bits/stdc++.h>
using namespace std;
void Debug() { cout << '\n'; }
template <class FIRST, class... REST>
void Debug(FIRST arg, REST... rest) {
  cout << arg << " ";
  Debug(rest...);
}
template <class T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  if (!v.empty()) {
    for (int i = int(0); i < int((int)(v).size() - 1); i++) out << v[i] << ", ";
    out << v.back();
  }
  out << "]";
  return out;
}
template <class S, class T>
ostream& operator<<(ostream& out, const pair<S, T>& v) {
  out << "(" << v.first << ", " << v.second << ")";
  return out;
}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const long long mod = 1000000007;
const int inf = 1 << 30;
const long long linf = 1LL << 60;
const double PI = 3.14159265358979323846;
int N, M;
int A[MAX_N];
int prime[4010];
int np[4010];
map<int, int> D;
int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
void solve() {
  for (int i = 2; i < 4000; i++) {
    if (np[i]) continue;
    prime[M++] = i;
    for (int j = i * 2; j < 4000; j += i) {
      np[j] = 1;
    }
  }
  cin >> N;
  int g = 0;
  for (int i = int(0); i < int(N); i++) {
    cin >> A[i];
    g = gcd(g, A[i]);
  }
  if (count(A, A + N, A[0]) == N) {
    cout << -1 << "\n";
    return;
  }
  for (int i = int(0); i < int(N); i++) A[i] /= g;
  int res = N;
  for (int q = int(0); q < int(M); q++) {
    int p = prime[q];
    int tmp = 0;
    for (int i = int(0); i < int(N); i++) {
      if (A[i] % p == 0) {
        tmp++;
        while (A[i] % p == 0) A[i] /= p;
      }
    }
    res = min(res, N - tmp);
  }
  for (int i = int(0); i < int(N); i++) {
    if (A[i] != 1) D[A[i]]++;
  }
  for (auto p : D) {
    res = min(res, N - p.second);
  }
  cout << res << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed;
  cout.precision(20);
  srand((unsigned int)time(NULL));
  solve();
  return 0;
}
