N = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) sumb = [0] * N sumb[0] = B[0] for i in range(1,N): sumb[i] = sumb[i-1] ^ B[i] C = [0] * (N + 1) for i in range(1,N+1): C[i] = C[i-1] if sumb[i-1] == 0: C[i] += 1 ans = 0 right = 0 now = 0 for left in range(N): while right < N and now + A[right] == now ^ A[right]: now += A[right] right += 1 ans += C[right] - C[left] now -= A[left] print(ans)