#include #include #include #include #include using namespace std; using m32 = atcoder::modint998244353; struct RollingHashed{ atcoder::static_modint<998244053> a; atcoder::static_modint<1000000009> b; unsigned int base = 357; RollingHashed(unsigned long long c = 0){ a = c; b = c; } bool operator==(RollingHashed r) const { return a == r.a && b == r.b; } RollingHashed& parallel_add(RollingHashed r) { a += r.a; b += r.b; return *this; } RollingHashed& parallel_subtract(RollingHashed r) { a -= r.a; b -= r.b; return *this; } bool operator<(RollingHashed r) const { return (a == r.a) ? (b.val() < r.b.val()) : (a.val() < r.a.val()); } RollingHashed& operator<<=(unsigned long long r){ a *= atcoder::static_modint<998244053>(base).pow(r); b *= atcoder::static_modint<1000000009>(base).pow(r); return *this; } RollingHashed operator<<(unsigned long long r){ auto buf = *this; buf <<= r; return buf; } }; vector unsquared; vector> factor_list; vector hashed; int Z = 1000000; int main(){ unsquared.assign(Z+1,0); for(int i=1; i<=Z; i++) unsquared[i] = i; for(int i=1; i*i<=Z; i++) for(int k=1; k*i*i<=Z; k++) unsquared[k*i*i] = k; factor_list.resize(Z+1); for(int i=2; i*i<=Z; i++) if(factor_list[i].empty()) for(int j=i; j<=Z; j+=i) factor_list[j].push_back(i); hashed.resize(Z+1); for(int i=2; i<=Z; i++) if(factor_list[i].size() == 1){ RollingHashed g = RollingHashed(1) << i; hashed[i] = g; } int N; cin >> N; vector A(N); vector prime_flag(Z+1, 0); for(auto& a : A){ int x; cin >> x; a = unsquared[x]; } map cnt; RollingHashed nowhash = RollingHashed(0); cnt[nowhash]++; for(auto& a : A){ for(int c : factor_list[a]){ if(prime_flag[c] == 0) nowhash.parallel_add(hashed[c]); else nowhash.parallel_subtract(hashed[c]); prime_flag[c] ^= 1; } cnt[nowhash]++; } long long ans = 0; for(auto a : cnt) ans += (long long)a.second * (a.second-1) / 2; cout << ans << endl; return 0; }