#include #include using namespace std; using namespace atcoder; //const long nPrime = 1000000007; //const long nPrime = 998244353; typedef long long ll; int main() { ll n; cin >> n; vector viA(n),viB(n),viBSum1(n+1); for(ll i = 0; i < n; i++){ cin >> viA[i]; } ll nB=0; for(ll i = 0; i < n; i++){ cin >> viB[i]; nB ^= viB[i]; viBSum1[i+1] = viBSum1[i]+nB; } ll nA = 0, nXOR = 0, iTmp = 0; nB = 0; ll nAns = 0; for(ll i = 1; i <= n; i++){ nA += viA[i-1]; nXOR ^= viA[i-1]; nB ^= viB[i-1]; while(nA != nXOR){ nA -= viA[iTmp]; nXOR ^= viA[iTmp]; iTmp++; } if(nB==0){ nAns += (i-iTmp)-(viBSum1[i]-viBSum1[iTmp])-viB[i-1]; } else { nAns += viBSum1[i]-viBSum1[iTmp]-viB[i-1]; } } cout << nAns << endl; return 0; }