#include <bits/stdc++.h>
int isp[10000050], l = 0, a[300005];
int sum[20000000] = {0};
void g() {
  sum[0] = sum[1] = 1;
  for (int i = 2; i <= 15000000; i++) {
    if (sum[i] == 0) {
      isp[++l] = i;
      for (int j = i + i; j <= 15000000; j += i) sum[j] = 1;
    }
  }
}
int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
int main() {
  g();
  memset(sum, 0, sizeof(sum));
  int n, ans = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  int gc = a[1];
  for (int i = 2; i <= n; i++) gc = gcd(gc, a[i]);
  for (int i = 1; i <= n; i++) {
    sum[a[i] / gc]++;
    if (sum[a[i] / gc] == n) return printf("-1") & 0;
  }
  for (int i = 1; i <= l; i++) {
    int tot = 0;
    for (int j = isp[i]; j <= 15000000; j += isp[i]) tot += sum[j];
    if (tot > ans) ans = tot;
  }
  printf("%d", n - ans);
}
