#include <bits/stdc++.h>
using namespace std;
const int siz = 3e5 + 5;
int n, m, a[siz];
int pr[15000005];
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int32_t main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  int g = a[0];
  for (int i = 1; i < n; i++) g = gcd(g, a[i]);
  int mx = 1;
  for (int i = 0; i < n; i++) a[i] /= g, mx = max(mx, a[i]);
  int z = 0;
  for (int i = 0; i < n; i++)
    if (a[i] != 1) z = 1;
  if (!z) return cout << -1 << endl, 0;
  vector<int> v;
  for (int i = 2; i * i <= 15000000; i++) {
    if (pr[i]) continue;
    for (int j = 2 * i; j <= mx; j += i) pr[j] = 1;
  }
  for (int i = 2; i <= 15000000; i++)
    if (!pr[i]) v.push_back(i);
  memset(pr, 0, sizeof pr);
  for (int i = 0; i < n; i++) pr[a[i]]++;
  int ans = n;
  for (int i = 0; i < v.size(); i++) {
    int cnt = 0;
    for (int j = v[i]; j <= mx; j += v[i]) cnt += pr[j];
    ans = min(ans, n - cnt);
  }
  cout << ans << endl;
}
