Smallest possible sum of gcd(a, b) running N times