#include <bits/stdc++.h>
using namespace std;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
const int maxn = 1.5e7;
int p[maxn + 1];
map<int, int> hsh;
int gcd(int a, int b) {
  if (a < b) swap(a, b);
  if (b == 0) return a;
  return gcd(a % b, b);
}
void prime(int n) {
  if (n % 2 == 0) {
    hsh[2]++;
    while (n % 2 == 0) {
      n /= 2;
    }
  }
  for (int i = 3; i <= sqrt(n); i += 2) {
    if (n % i == 0) {
      hsh[i]++;
      while (n % i == 0) {
        n /= i;
      }
    }
  }
  if (n != 1) {
    hsh[n]++;
  }
}
void sieve() {
  for (long long i = (long long)(2); i <= (long long)(maxn); ++i) {
    if (p[i] == 0) {
      for (int j = i; j <= maxn; j += i) {
        p[j] = i;
      }
    }
  }
}
int main() {
  int n;
  scanf("%d", &n);
  memset(p, 0, sizeof(p));
  sieve();
  int a[n];
  int g;
  for (long long i = 0; i < (long long)(n); ++i) {
    scanf("%d", &a[i]);
    if (i == 0) {
      g = a[i];
    } else {
      g = gcd(g, a[i]);
    }
  }
  for (long long i = 0; i < (long long)(n); ++i) {
    a[i] /= g;
    while (a[i] != 1) {
      int div = p[a[i]];
      hsh[div]++;
      while (a[i] % div == 0) {
        a[i] /= div;
      }
    }
  }
  int ans = 0;
  for (auto it : hsh) {
    ans = max(ans, it.second);
  }
  if (n - ans == n)
    printf("-1");
  else
    printf("%d", n - ans);
  return 0;
}
