import
java.util.*;
class
GFG{
static
final
int
MAXN =
100001
;
static
int
[]spf =
new
int
[MAXN];
static
void
sieve()
{
spf[
1
] =
1
;
for
(
int
i =
2
; i < MAXN; i++)
spf[i] = i;
for
(
int
i =
4
; i < MAXN; i +=
2
)
spf[i] =
2
;
for
(
int
i =
3
; i * i < MAXN; i++)
{
if
(spf[i] == i)
{
for
(
int
j = i * i; j < MAXN; j += i)
if
(spf[j] == j)
spf[j] = i;
}
}
}
static
Vector<Integer> getFactorization(
int
x)
{
Vector<Integer> ret =
new
Vector<>();
while
(x !=
1
)
{
ret.add(spf[x]);
x = x / spf[x];
}
return
ret;
}
static
int
__gcd(
int
a,
int
b)
{
return
b ==
0
? a : __gcd(b, a % b);
}
static
int
minimumRemovals(
int
a[],
int
n)
{
int
g =
0
;
for
(
int
i =
0
; i < n; i++)
g = __gcd(a[i], g);
HashMap<Integer, Integer> mpp =
new
HashMap<>();
for
(
int
i =
0
; i < n; i++)
a[i] = a[i] / g;
for
(
int
i =
0
; i < n; i++)
{
Vector<Integer> p = getFactorization(a[i]);
HashSet<Integer> s =
new
HashSet<>();
for
(
int
j =
0
; j < p.size(); j++)
{
s.add(p.get(j));
}
for
(
int
it: s)
{
int
el = it;
if
(mpp.containsKey(el))
{
mpp.put(el, mpp.get(el) +
1
);
}
else
{
mpp.put(el,
1
);
}
}
}
int
mini = Integer.MAX_VALUE;
int
mini1 = Integer.MAX_VALUE;
for
(Map.Entry<Integer, Integer> it : mpp.entrySet())
{
int
fir = it.getKey();
int
sec = it.getValue();
if
((n - sec) <= mini)
{
mini = n - sec;
}
}
if
(mini != Integer.MAX_VALUE)
return
mini;
else
return
-
1
;
}
public
static
void
main(String[] args)
{
int
a[] = {
6
,
9
,
15
,
30
};
int
n = a.length;
sieve();
System.out.print(minimumRemovals(a, n));
}
}