#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int N = 5 + 15e6;
const int INF = 1e9;
int a[N];
int ans[N];
bool isPrime[N], vis[N];
vector<int> primes;
void sieve(int n) {
  memset(isPrime, 1, sizeof isPrime);
  isPrime[0] = isPrime[1] = 0;
  for (int i = 2; i * i <= n; i++) {
    if (isPrime[i]) {
      for (int j = i * i; j <= n; j += i) isPrime[j] = 0;
    }
  }
  for (int i = 0; i <= n; i++)
    if ((isPrime[i]) && (!vis[i])) primes.push_back(i);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t, mx = -1, n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> t;
    ++a[t];
    mx = max(mx, t);
    if ((t > 1) && (!vis[t])) {
      primes.push_back(t);
      vis[t] = 1;
    }
  }
  sieve(mx + 1);
  for (int j = 0; j < primes.size(); ++j) {
    int r = primes[j];
    for (int i = r; i <= mx; i += r) ans[r] += a[i];
  }
  int amx = 0;
  for (int i = 1; i <= mx; ++i)
    if ((ans[i] != n) && (ans[i] > amx)) amx = ans[i];
  if (amx == 0)
    cout << -1;
  else
    cout << n - amx;
}
