#include <bits/stdc++.h>                                                                              
using namespace std;                                                                                  
using ll = long long;                                                                                 
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }               
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }               
#define rep(i,n) for (int i=0; i< (n); ++i)                                                           
typedef pair<int, int> P;                                                                             
                                                                                                      
int main() {                                                                                          
  ll n;                                                                                               
  cin >> n;                                                                                           
  vector<ll> a(n);                                                                                    
  rep(i,n) cin >> a[i];                                                                               
  ll ans = n*(n+1)/2;                                                                                 
  ll cnt = 0;                                                                                         
                                                                                                      
  ll l=0;                                                                                             
  ll r=0;                                                                                             
  ll sum=a[0];                                                                                        
  ll xsum=a[0];                                                                                       
  while (r<n) {                                                                                       
    if (sum == xsum) {                                                                                
      r++;                                                                                            
      if (r<n) {                                                                                      
        sum += a[r];                                                                                  
        xsum ^= a[r];                                                                                 
      }                                                                                               
    } else {                                                                                          
      cnt+=n-r;                                                                                       
      sum -= a[l];                                                                                    
      xsum ^= a[l];                                                                                   
      l++;                                                                                            
    }                                                                                                 
  }                                                                                                   
  cout << ans-cnt << endl;                                                                            
  return 0;                                                                                           
}                                    

Measured memory_bytes: 1792