#pragma GCC target("avx2,bmi,bmi2") #pragma GCC optimize("O3") #include #include #include uint32_t gcd(uint32_t x, uint32_t y) { if (x == 0 || y == 0) { return x | y; } int x_tz = __builtin_ctz(x); int y_tz = __builtin_ctz(y); int k = x_tz < y_tz ? x_tz : y_tz; x >>= x_tz; y >>= y_tz; while (x != y) { if (x < y) { uint32_t t = x; x = y; y = t; } x -= y; x >>= __builtin_ctz(x); } return x << k; } int main(void) { size_t n; scanf("%zu", &n); uint32_t a[100]; for (size_t i = 0; i < n; ++i) { scanf("%" SCNu32, &a[i]); } uint32_t cnt = 0; for (size_t i = 0; i < n; ++i) { for (size_t j = i + 1; j < n; ++j) { uint32_t d = gcd(a[i], a[j]); for (size_t k = j + 1; k < n; ++k) { if (gcd(d, a[k]) == 1) { ++cnt; } } } } printf("%" PRIu32 "\n", cnt); }