from collections import * N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) D = [0] * (N + 1) for i in range(N): D[i + 1] = D[i] ^ B[i] Bc = [[0] * (N + 1) for i in range(2)] for i in range(N): Bc[0][i + 1] = Bc[0][i] + 1 - D[i] Bc[1][i + 1] = Bc[1][i] + D[i] Q = deque() s, x = 0, 0 ans = 0 for i in range(N): Q.append(A[i]) s += A[i] x ^= A[i] while s != x: v = Q.popleft() s -= v x ^= v pre = i - len(Q) ans += Bc[B[i]][i + 1] - Bc[B[i]][pre + 1] print(ans)