#include <bits/stdc++.h>
using namespace std;
int n, prime[15000010], vis[15000010], ha[15000010], x[300100], ans, now, mx,
    cnt;
bool flag;
int read() {
  int tot = 0, fh = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') fh = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    tot = tot * 10 + c - '0';
    c = getchar();
  }
  return tot * fh;
}
void getstr(char *a) {
  char ch = getchar();
  int len = 0;
  while (ch < 'a' || ch > 'z') ch = getchar();
  while (ch >= 'a' && ch <= 'z') {
    a[++len] = ch;
    ch = getchar();
  }
}
int gcd(int x, int y) {
  int z;
  while (y) {
    z = x % y;
    x = y;
    y = z;
  }
  return x;
}
int main() {
  n = read();
  flag = true;
  for (int i = 1; i <= n; i++) {
    x[i] = read();
    if (i == 1)
      now = x[i];
    else {
      now = gcd(now, x[i]);
      if (x[i] != x[i - 1]) flag = false;
    }
    mx = max(mx, x[i]);
  }
  if (flag) {
    cout << -1 << "\n";
    return 0;
  }
  for (int i = 2; i <= mx; i++) {
    if (!vis[i]) prime[++cnt] = i;
    for (int j = 1; j <= cnt && prime[j] <= mx / i; j++) {
      vis[i * prime[j]] = 1;
      if (i % prime[j] == 0) break;
    }
  }
  for (int i = 1; i <= n; i++) x[i] /= now;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; prime[j] * prime[j] <= x[i] && j <= cnt; j++) {
      if (x[i] == 1) break;
      if (vis[x[i]] == 0) {
        ha[x[i]]++;
        x[i] = 1;
        break;
      }
      if (x[i] % prime[j] == 0) ha[prime[j]]++;
      while (x[i] % prime[j] == 0) x[i] /= prime[j];
    }
    if (x[i] != 1) ha[x[i]]++;
  }
  for (int i = 1; i <= mx; i++)
    if (ha[i] > ans) ans = ha[i];
  cout << n - ans << "\n";
  return 0;
}
