#include <bits/stdc++.h>
using namespace std;
int32_t book[15000000 + 5];
int32_t prime[1000000 + 5];
int32_t num[1000000 + 5];
int32_t minx[1000000 + 5];
int32_t numminx[1000000 + 5];
void init() {
  memset(book, 0, sizeof(book));
  memset(prime, 0, sizeof(prime));
  memset(num, 0, sizeof(num));
  memset(minx, 0x3f3f3f3f, sizeof(minx));
  memset(numminx, 0, sizeof(numminx));
  for (int32_t i = 2; i <= 15000000; i++) {
    if (!book[i]) {
      prime[++prime[0]] = i;
      book[i] = prime[0];
    }
    for (int32_t j = 1; j <= prime[0]; j++) {
      if (prime[j] * i > 15000000) {
        break;
      }
      book[i * prime[j]] = j;
      if (i % prime[j] == 0) {
        break;
      }
    }
  }
  return;
}
void work(int32_t a) {
  while (a != 1) {
    int32_t aa = a;
    int32_t t = prime[book[a]], inx = 0;
    num[book[a]]++;
    while (a % t == 0) {
      inx++;
      a /= t;
    }
    if (inx < minx[book[aa]]) {
      minx[book[aa]] = inx;
      numminx[book[aa]] = 1;
    } else if (inx == minx[book[aa]]) {
      numminx[book[aa]]++;
    }
  }
}
int32_t main() {
  init();
  int32_t n, a;
  int32_t minn = 0x3f3f3f3f;
  scanf("%d", &n);
  for (int32_t i = 1; i <= n; i++) {
    scanf("%d", &a);
    work(a);
  }
  for (int32_t i = 1; i <= prime[0]; i++) {
    if (!num[i]) continue;
    if (num[i] == n) {
      minn = min(numminx[i], minn);
    } else {
      minn = min(n - num[i], minn);
    }
  }
  if (minn == 0x3f3f3f3f || minn == 0 || minn == n)
    printf("-1\n");
  else
    printf("%d\n", minn);
  return 0;
}
