#include using namespace std; #ifdef _RUTHEN #include "debug.hpp" #else #define show(...) true #endif using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) template using V = vector; int main() { ios::sync_with_stdio(false); cin.tie(0); ll N; cin >> N; V A(N), B(N); rep(i, N) cin >> A[i]; rep(i, N) cin >> B[i]; int r = 0, c = 0; ll s = 0, xs = 0, ans = 0; for (int l = 0; l < N; l++) { // hoge while (r < N && (s + A[r]) == (xs ^ A[r])) { s += A[r]; xs ^= A[r]; c += B[r]; r++; } show(l, r, s, xs, c, ans); if (B[l] == 0) { ans += r - l - c; } s -= A[l]; xs ^= A[l]; c -= B[l]; } cout << ans << '\n'; return 0; }