#include <bits/stdc++.h>
using namespace std;
const int sz = 15000001;
int n;
int sieve[sz];
int v[300001];
int cnt[sz];
inline void solve() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &v[i]);
  }
  for (int i = 2; i < sz; i++)
    if (sieve[i] == 0) {
      for (int j = i; j < sz; j += i) sieve[j] = i;
    }
  for (int i = 0; i < n; i++) {
    int x = v[i];
    if (x == 1) continue;
    vector<int> f;
    while (x != 1) {
      f.push_back(sieve[x]);
      x /= sieve[x];
    }
    int cur = f[f.size() - 1];
    cnt[cur]++;
    for (int j = f.size() - 2; j >= 0; j--) {
      if (f[j] == f[j + 1])
        cur *= f[j];
      else
        cur = f[j];
      cnt[cur]++;
    }
  }
  int otv = n;
  for (int i = 0; i < sz; i++) {
    if (n != cnt[i]) otv = min(n - cnt[i], otv);
  }
  if (otv == n)
    printf("%d", -1);
  else
    printf("%d", otv);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q = 1;
  for (; q > 0; q--) {
    solve();
    cout << '\n';
  }
}
