import math def get_factors(x): factors = set() for i in range(1, int(math.isqrt(x)) + 1): if x % i == 0: factors.add(i) factors.add(x // i) return factors def mobius(d): if d == 1: return 1 factors = {} temp = d for i in range(2, int(math.isqrt(temp)) + 1): if i * i > temp: break if temp % i == 0: factors[i] = 1 temp //= i if temp % i == 0: return 0 if temp > 1: factors[temp] = 1 return (-1) ** len(factors) n = int(input()) a = [int(input()) for _ in range(n)] all_factors = set() for num in a: factors = get_factors(num) all_factors.update(factors) c_d = {} for d in all_factors: count = 0 for num in a: if num % d == 0: count += 1 c_d[d] = count ans = 0 for d in all_factors: mu = mobius(d) if mu == 0: continue count = c_d[d] if count >= 3: ans += mu * (count * (count - 1) * (count - 2) // 6) print(ans)