Approach hintTry it first, then revealHide
Divide every number by the overall gcd; the new gcd exceeds it exactly when some prime divides all kept values. Count, with a smallest-prime-factor sieve, how many reduced values each prime divides and keep the best prime.