#include <bits/stdc++.h>
using namespace std;
const int MXN = (int)3e5 + 7;
const int MAXN = (int)2e7;
int lp[MAXN + 11], n, a[MXN], cnt[MAXN + 11];
long long binpow(long long a, int n) {
  if (!n) return 1;
  if (n & 1) return binpow(a, n - 1) * a;
  long long b = binpow(a, n / 2);
  return b * b;
}
void comp() {
  for (int i = 2; i <= MAXN; i++) {
    if (!lp[i]) {
      for (int j = i; j <= MAXN; j += i) {
        lp[j] = i;
      }
    }
  }
}
void makeit(int x) {
  while (x > 1) {
    int y = lp[x], val = 0;
    while (x % y == 0) {
      x /= y;
      val++;
      int num = binpow(y, val);
      cnt[num]++;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  comp();
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    makeit(a[i]);
  }
  long long am = 0, num = 0, ans = 0;
  for (int i = 2; i <= MAXN; i++) {
    if (lp[i] == i && cnt[i]) {
      long long kek = i;
      while (cnt[kek] && kek < MAXN) {
        if (cnt[kek] < n && am < cnt[kek]) {
          am = cnt[kek];
          num = kek;
        }
        if (kek * i < MAXN) {
          kek *= i;
        } else {
          break;
        }
      }
    }
  }
  if (!num) return cout << -1, 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] % num != 0) ans++;
  }
  cout << ans;
  return 0;
}
