#include using namespace std; using i64 = long long; #define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++) #define all(x) x.begin(),x.end() #define STRINGIFY(n) #n #define TOSTRING(n) STRINGIFY(n) #define PREFIX "#" TOSTRING(__LINE__) "| " #define debug(x) \ { \ std::cout << PREFIX << #x << " = " << x << std::endl; \ } std::ostream& output_indent(std::ostream& os, int ind) { for(int i = 0; i < ind; i++) os << " "; return os; } template std::ostream& operator<<(std::ostream& os, const std::pair& p); template std::ostream& operator<<(std::ostream& os, const std::vector& v); template std::ostream& operator<<(std::ostream& os, const std::pair& p) { return (os << "(" << p.first << ", " << p.second << ")"); } template std::ostream& operator<<(std::ostream& os, const std::vector& v) { os << "["; for(int i = 0;i < v.size();i++) os << v[i] << ", "; return (os << "]"); } template static inline std::vector ndvec(size_t&& n, T val) { return std::vector(n, std::forward(val)); } template static inline auto ndvec(size_t&& n, Tail&&... tail) { return std::vector(tail)...))>(n, ndvec(std::forward(tail)...)); } template struct chain { Cond cond; chain(Cond cond) : cond(cond) {} template bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; } }; template chain make_chain(Cond cond) { return chain(cond); } int main() { i64 N; cin >> N; vector A(N); rep(i,0,N) cin >> A[i]; vector B(N); rep(i,0,N) cin >> B[i]; i64 l = 0; i64 bits = 0; i64 b_sum = 0; i64 l_sum = 0; vector cnt(2); i64 ans = 0; for(int r = 0; r < N; r++) { while(bits & A[r]) { bits = bits & (~A[l]); l_sum ^= B[l]; cnt[l_sum]--; l++; } bits |= A[r]; b_sum ^= B[r]; //cout << l << " " << r << " " << b_sum << "^" << l_sum << " " << cnt[0] << ":" << cnt[1] << endl; ans += cnt[b_sum] + (b_sum == l_sum); cnt[b_sum]++; } cout << ans << endl; }