#include <bits/stdc++.h>
using namespace std;
vector<int> pri;
map<int, int> mp;
int A[300001];
int ch[15000001];
int GCD(int a, int b) {
  if (b == 0) return a;
  return GCD(b, a % b);
}
int main() {
  for (int i = 2; i <= 15000000; i++) {
    if (ch[i] != 0) continue;
    pri.push_back(i);
    for (long long j = (long long)i * i; j <= 15000000; j += i) {
      if (ch[j] == 0) ch[j] = pri.size();
    }
  }
  int n;
  scanf("%d", &n);
  scanf("%d", &A[0]);
  int gcd = A[0];
  for (int i = 1; i < n; i++) {
    scanf("%d", &A[i]);
    gcd = GCD(gcd, A[i]);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    long long a = A[i] / gcd;
    while (ch[a] != 0) {
      int j = ch[a] - 1;
      int b = pri[j];
      if (a % b == 0) {
        while (a % b == 0) a /= b;
        mp[b] += 1;
        ans = max(ans, mp[b]);
      }
    }
    if (a != 1) {
      mp[a] += 1;
      ans = max(ans, mp[a]);
    }
  }
  if (ans == 0)
    printf("-1\n");
  else
    printf("%d\n", n - ans);
  return 0;
}
