#include <bits/stdc++.h>
using namespace std;
const int maxn = 1.5e7 + 5;
int pri[maxn], a[maxn];
int n;
int gcd(int a, int b) { return a == 0 ? b : gcd(b % a, a); }
int main() {
  int n, temp, g = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &temp);
    a[temp]++;
    if (!g)
      g = temp;
    else
      g = gcd(g, temp);
  }
  int cnt, ans = n;
  for (int i = g + 1; i < maxn; i++)
    if (!pri[i]) {
      cnt = 0;
      for (int j = i; j < maxn; j += i) {
        pri[j] = 1;
        cnt += a[j];
      }
      ans = min(ans, n - cnt);
    }
  if (ans < n)
    cout << ans << endl;
  else
    cout << -1 << endl;
  return 0;
}
