#include <algorithm>
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl "\n"
#define output(a) cout<<a<<endl;
#define outputv(arr) for(auto i:arr){cout<<i<<" ";}cout<<endl;
#define outputp(a) cout<<a.first<<" "<<a.second<<endl;
#define all(v) v.begin(), v.end()
#define yes cout<<"YES"<<endl;return;
#define no cout<<"NO"<<endl;return;
#define pii pair<int,int>
using ll = long long;
const ll MOD = 1e9 + 7;
using namespace std;
void soln()
{
ll n;
cin>>n;
vector<int> a(n+1);
vector<int> pre(n+1,0);
for(int i=1;i<=n;i++)
{
cin>>a[i];
pre[i] = pre[i-1]^a[i];
}
vector<int> sq;
{
for(int i=0;i*i<=(2*n)+1;i++){sq.push_back(i*i);}
}
int maxe = *max_element(1 + all(pre));
ll exist_odd = 0;
for(auto i:sq)
{
vector<int> seen_till_now(maxe + 1,0);
//cout<<i<<endl;
for(int j=1;j<=n;j++)
{
int req = (i^pre[j]);
if(req > maxe){seen_till_now[pre[j]]++;continue;}
if(req == 0){exist_odd+=1;}
// if(seen_till_now[req]>0){cout<<j<<" ";}
exist_odd += seen_till_now[req];
seen_till_now[pre[j]]++;
}
//cout<<endl;
}
cout<<(n*(n+1))/2 - exist_odd<<endl;
}
signed main() {
#ifdef LOCAL_PROJECT
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
freopen("error.txt", "w", stderr);
#endif
IOS
ll t;
t=1;
cin>>t;
while(t--)
{
soln();
}
return 0;
}
1180A - Alex and a Rhombus | 445A - DZY Loves Chessboard |
1372A - Omkar and Completion | 159D - Palindrome pairs |
981B - Businessmen Problems | 1668A - Direction Change |
1667B - Optimal Partition | 1668B - Social Distance |
88B - Keyboard | 580B - Kefa and Company |
960A - Check the string | 1220A - Cards |
897A - Scarborough Fair | 1433B - Yet Another Bookshelf |
1283B - Candies Division | 1451B - Non-Substring Subsequence |
1408B - Arrays Sum | 1430A - Number of Apartments |
1475A - Odd Divisor | 1454B - Unique Bid Auction |
978C - Letters | 501B - Misha and Changing Handles |
1496A - Split it | 1666L - Labyrinth |
1294B - Collecting Packages | 1642B - Power Walking |
1424M - Ancient Language | 600C - Make Palindrome |
1669D - Colorful Stamp | 1669B - Triple |