#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int N = 0, C = 0;
  char tf = getchar();
  for (; !isdigit(tf); tf = getchar()) C |= tf == '-';
  for (; isdigit(tf); tf = getchar()) N = (N << 1) + (N << 3) + (tf ^ 48);
  return C ? -N : N;
}
const int N = 300010;
const int M = 15000010;
int n, m, b, bb, g, mx;
int a[N], p[M / 10], cnt[M];
bool v[M];
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline void P() {
  v[1] = 1;
  for (int i = 2; i < M; ++i) {
    if (!v[i]) p[++m] = i;
    for (int j = 1; j <= m && i * p[j] < M; ++j) {
      v[i * p[j]] = 1;
      if (!(i % p[j])) break;
    }
  }
}
int main() {
  n = read();
  P();
  for (int i = 1; i <= n; ++i) g = gcd(a[i] = read(), g);
  for (int i = 1; i <= n; ++i) {
    b = a[i] / g, bb = sqrt(b);
    for (int j = 1; j <= m && p[j] <= bb; ++j)
      if (!(b % p[j])) {
        ++cnt[p[j]];
        while (!(b % p[j])) b /= p[j];
      }
    if (b > 1) ++cnt[b];
  }
  for (int i = 2; i < M; ++i) mx = max(mx, cnt[i]);
  if (!mx)
    puts("-1");
  else
    printf("%d\n", n - mx);
  return 0;
}
