#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int lp[15000005];
int qtd[15000005];
int v[300005];
int gcd(int a, int b) {
  if (!b) return a;
  return gcd(b, a % b);
}
int main() {
  int n;
  lp[1] = 1;
  for (int i = 2; i <= 15000000; i++) {
    if (!lp[i]) {
      lp[i] = i;
      for (long long j = (long long)i * i; j <= 15000000; j += i) lp[j] = i;
    }
  }
  scanf("%d", &n);
  int cur = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &v[i]);
    if (!cur)
      cur = v[i];
    else
      cur = gcd(cur, v[i]);
  }
  if (n == 1 or cur == *max_element(v, v + n)) {
    printf("-1\n");
    return 0;
  }
  int ans = n - 1;
  for (int i = 0; i < n; i++) {
    v[i] /= cur;
    while (v[i] > 1) {
      qtd[lp[v[i]]]++;
      ans = min(ans, n - qtd[lp[v[i]]]);
      int aux = lp[v[i]];
      while (v[i] % aux == 0) v[i] /= aux;
    }
  }
  printf("%d\n", ans);
  return 0;
}
