#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return (b == 0 ? a : gcd(b, a % b)); }
int lcm(int a, int b) { return (a * b) / gcd(a, b); }
inline long long mod(long long n, long long m) {
  long long ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}
int exp(int a, int b) {
  int result = 1;
  while (b > 0) {
    if (b & 1) result = result * a;
    b >>= 1;
    a = a * a;
  }
  return result;
}
const int v = 1.5 * 1e7 + 1;
vector<int> primos(v);
vector<int> gprimos;
void euclides() {
  for (int i = 2; i < v; ++i) {
    if (primos[i] == 0) {
      primos[i] = i;
      gprimos.push_back(i);
    }
    for (int j = 0; j < (int)gprimos.size() && gprimos[j] <= primos[i] &&
                    i * gprimos[j] < v;
         ++j)
      primos[i * gprimos[j]] = gprimos[j];
  }
}
void solve() {
  int n;
  cin >> n;
  vector<int> vet(v);
  vector<int> guard(n);
  int res;
  for (int i = 0; i < n; i++) {
    cin >> guard[i];
    if (i == 0)
      res = guard[i];
    else
      res = gcd(res, guard[i]);
  }
  for (int &i : guard) {
    i /= res;
  }
  for (int &i : guard) {
    int x = i;
    while (x > 1) {
      int men = primos[x];
      while (x % men == 0) {
        x /= men;
      }
      vet[men]++;
    }
  }
  int maior = 0;
  for (int &i : gprimos) {
    if (vet[i] != n) {
      maior = max(maior, vet[i]);
    }
  }
  cout << (maior == 0 ? -1 : n - maior) << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  euclides();
  solve();
}
