#include <bits/stdc++.h>
using namespace std;
const int maxn = 300005;
const int maxm = 5005;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  int n;
  scanf("%d", &n);
  int a[maxn];
  bool exist[maxm];
  for (int i = 0; i < maxm; ++i) exist[i] = true;
  int i = 2;
  while (i < maxm) {
    int j = i + i;
    if (exist[i]) {
      while (j < maxm) {
        exist[j] = false;
        j += i;
      }
    }
    i += 1;
  }
  vector<int> primes;
  for (int i = 2; i < maxm; ++i)
    if (exist[i]) {
      primes.push_back(i);
    }
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  int cur_gcd = gcd(a[0], a[1]);
  for (int i = 2; i < n; ++i)
    if (cur_gcd != 1) cur_gcd = gcd(cur_gcd, a[i]);
  for (int i = 0; i < n; ++i) a[i] = a[i] / cur_gcd;
  vector<int> nums;
  for (int i = 0; i < n; ++i) {
    int cur = a[i];
    for (int j = 0; j < primes.size(); ++j)
      if (primes[j] > cur)
        break;
      else if (cur % primes[j] == 0) {
        nums.push_back(primes[j]);
        while (cur % primes[j] == 0) {
          cur = cur / primes[j];
        }
      }
    if (cur > 1) nums.push_back(cur);
  }
  sort(nums.begin(), nums.end());
  int ans = 0;
  int left = 0, right = 0;
  while (right < nums.size()) {
    while (right < nums.size() && nums[right] == nums[left]) right++;
    if (right - left > ans) {
      ans = right - left;
    }
    left = right;
  }
  if (ans == 0 || ans == n)
    cout << -1 << endl;
  else
    cout << n - ans << endl;
}
