#include <bits/stdc++.h>
using namespace std;
int ara[300005];
vector<int> v;
set<int> st;
map<int, int> cnt;
void seive() {
  bool vis[300005];
  memset(vis, 0, sizeof vis);
  for (int i = 2; i < 300005; i++) {
    if (!vis[i]) {
      v.push_back(i);
      for (int j = i + i; j < 300005; j += i) {
        vis[j] = 1;
      }
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  seive();
  while (cin >> n) {
    cnt.clear();
    st.clear();
    for (int i = 0; i < n; i++) {
      cin >> ara[i];
      int a = ara[i];
      for (int j = 0; j < v.size(); j++) {
        if (v[j] * v[j] > a) break;
        if (a % v[j] == 0) {
          int b = 1;
          while (a % v[j] == 0) {
            a /= v[j];
            b *= v[j];
            st.insert(b);
            cnt[b]++;
          }
        }
      }
      if (a != 1) {
        cnt[a]++;
        st.insert(a);
      }
    }
    int ans = n;
    for (set<int>::iterator it = st.begin(); it != st.end(); ++it) {
      if (n - cnt[*it] != 0) ans = min(n - cnt[*it], ans);
    }
    if (n == ans) ans = -1;
    cout << ans << endl;
  }
  return 0;
}
