#include <bits/stdc++.h>
using namespace std;
vector<int> in(15000005);
vector<int> visited(15000005);
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n;
  cin >> n;
  int vgcd = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    in[a]++;
    if (i == 0) {
      vgcd = a;
    } else {
      vgcd = gcd(a, vgcd);
    }
  }
  int res = n;
  for (int i = vgcd + 1; i < 15000005; i++) {
    if (visited[i] == 0) {
      int tmp = 0;
      for (int j = i; j < 15000005; j += i) {
        visited[j] = 1;
        tmp += in[j];
      }
      res = min(res, n - tmp);
    }
  }
  cout << (res == n ? -1 : res) << endl;
  return 0;
}
