#include <bits/stdc++.h>
using namespace std;
int fact[15900000];
vector<int> prime;
vector<int> a;
int cnt[15900000];
int main() {
  for (int i = 2; i < 15900000; i++) {
    if (!fact[i]) {
      prime.push_back(i);
      fact[i] = i;
    }
    for (int e : prime) {
      if (e > fact[i] || e * i >= 15900000) {
        break;
      }
      fact[e * i] = e;
    }
  }
  int N;
  cin >> N;
  a.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    if (a[i] > 1) {
      for (int j = a[i]; j != 1;) {
        int pr = fact[j];
        int pow = pr;
        while (j % pr == 0 && j != 1) {
          cnt[pow] += 1;
          pow *= pr;
          j = j / pr;
        }
      }
    }
  }
  int result = N;
  for (int i = 0; i < 15900000; i++) {
    if (cnt[i] != N) {
      result = min(result, N - cnt[i]);
    }
  }
  if (result == N) {
    cout << -1 << endl;
    exit(0);
  } else {
    cout << result << endl;
  }
}
