#include <bits/stdc++.h>
using namespace std;
long long N, i, j, D, P, mn, B, MX, D2;
long long v[300005], ANS, ANS2;
int ok[15000005], nr[15000005];
bool pr[15000005];
long long GCD(long long A, long long B) {
  if (B == 0) return A;
  return GCD(B, A % B);
}
int main() {
  scanf("%lld", &N);
  for (i = 1; i <= N; i++) {
    scanf("%lld", &v[i]);
    MX = max(MX, v[i]);
    ok[v[i]]++;
    if (v[i] == 1) ANS++;
    if (i == 1)
      D = v[i];
    else
      D = GCD(D, v[i]);
    if (v[i] > 1) {
      if (D2 == 0)
        D2 = v[i];
      else
        D2 = GCD(D2, v[i]);
    }
  }
  if (ANS == N) {
    printf("-1");
    return 0;
  }
  if (D2 > D) {
    printf("%lld", ANS);
    return 0;
  }
  mn = N + 1;
  for (i = 2; i <= D; i++) {
    if (D == 1) break;
    if (D % i == 0) {
      P = i;
      while (D % i == 0) {
        D /= i;
        P *= 1LL * i;
      }
      B = 0;
      for (j = 1; j <= N; j++) {
        if (v[j] == 1) continue;
        if (v[j] % P != 0) B++;
      }
      mn = min(mn, B);
    }
  }
  ANS += mn;
  for (i = 2; i <= MX; i++) {
    if (pr[i] == false) {
      nr[i] += ok[i];
      for (j = 2 * i; j <= MX; j += i) {
        pr[j] = true;
        nr[i] += ok[j];
      }
    }
  }
  ANS2 = N + 1;
  for (i = 1; i <= MX; i++)
    if (nr[i] != N) ANS2 = min(ANS2, N - nr[i]);
  ANS = min(ANS, ANS2);
  if (ANS >= N)
    printf("-1");
  else
    printf("%lld", ANS);
  return 0;
}
