#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
typedef vector<vector<int> > VVI;
inline int mult(int x, int y) { return ((long long)x * y) % 1000000007; }
int power(int x, int y) {
  int ret = 1;
  while (y) {
    if (y & 1) ret = mult(ret, x);
    x = mult(x, x);
    y = y / 2;
  }
  return ret;
}
int gcd(int a, int b) {
  if (b) return gcd(b, a % b);
  return a;
}
int prime[15000005], countdiv[15000005];
void SieveOfEratosthenes() {
  for (int i = 2; i * i < 15000005; ++i) {
    if (!prime[i])
      for (int j = i * i; j < 15000005; j += i) prime[j] = i;
  }
  for (int i = 1; i < 15000005; ++i)
    if (!prime[i]) prime[i] = i;
}
int largestGCDSubsequence(vector<int>& arr, int n) {
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int element = arr[i];
    while (element > 1) {
      int divi = prime[element];
      ++countdiv[divi];
      ans = max(ans, countdiv[divi]);
      while (element % divi == 0) element /= divi;
    }
  }
  return ans;
}
int main() {
  int n, temp, g;
  vector<int> V;
  scanf("%d", &n);
  for (long long i = 0; i < n; i++) {
    scanf("%d", &temp);
    V.push_back(temp);
    if (i == 0)
      g = temp;
    else
      g = gcd(g, temp);
  }
  int maxi = 1;
  for (int i = 0; i < n; i++) {
    V[i] = V[i] / g;
    maxi = max(maxi, V[i]);
  }
  SieveOfEratosthenes();
  int t1 = largestGCDSubsequence(V, V.size());
  if (t1 == 0)
    cout << -1 << endl;
  else
    cout << n - t1 << endl;
  return 0;
}
