#include #include using namespace std; using namespace atcoder; using mint = modint998244353; //using mint = modint1000000007; using ll = long long; using ld = long double; using pll = pair; using tlll = tuple; constexpr ll INF = 1LL << 60; template bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;} template bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;} ll safemod(ll A, ll M) {return (A % M + M) % M;} ll divfloor(ll A, ll B) {if (B < 0) {return divfloor(-A, -B);} return (A - safemod(A, B)) / B;} ll divceil(ll A, ll B) {if (B < 0) {return divceil(-A, -B);} return divfloor(A + B - 1, B);} #define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false) class eratosthenes { public: vector isprime; vector primes; vector primeid; vector minfactor; vector mobius; eratosthenes(ll N) { isprime.assign(N + 1, true); primeid.assign(N + 1, -1); minfactor.assign(N + 1, -1); mobius.assign(N + 1, 1); isprime.at(0) = false, isprime.at(1) = false; minfactor.at(1) = 1; for (ll p = 2; p <= N; p++) { if (!isprime.at(p)) continue; primeid.at(p) = primes.size(); primes.emplace_back(p); minfactor.at(p) = p; mobius.at(p) = -1; for (ll k = 2; k * p <= N; k++) { isprime.at(k * p) = false; if (minfactor.at(k * p) == -1) minfactor.at(k * p) = p; if (k % p == 0) mobius.at(k * p) = 0; else mobius.at(k * p) *= -1; } } } vector factorize(ll n) { vector ret; while (n > 1) { ll p = minfactor.at(n); ll e = 0; while (minfactor.at(n) == p) { n /= p; e++; } ret.emplace_back(make_pair(p, e)); } return ret; } }; vector Zob; void init(ll M) { Zob.resize(M); srand((unsigned)time(NULL)); for (ll i = 0; i < M; i++) { Zob.at(i) = (rand() % (1LL << 31)) * (1LL << 31) + rand() % (1LL << 31); } } const ll M = 1000000; eratosthenes er(M); ll zobristhash(ll a) { auto pes = er.factorize(a); ll ret = 0; for (auto pe : pes) { auto [p, e] = pe; if (e % 2 == 1) { ret ^= Zob.at(er.primeid.at(p)); } } return ret; } int main() { ll N; cin >> N; vector A(N); for (ll i = 0; i < N; i++) { cin >> A.at(i); } init(er.primes.size()); vector B(N); for (ll i = 0; i < N; i++) { B.at(i) = zobristhash(A.at(i)); } vector S(N + 1); S.at(0) = 0; for (ll i = 0; i < N; i++) { S.at(i + 1) = S.at(i) ^ B.at(i); } map mp; for (ll i = 0; i < N + 1; i++) { mp[S.at(i)]++; } ll ans = 0; for (auto m : mp) { ll tmp = m.second * (m.second - 1) / 2; ans += tmp; } cout << ans << endl; }