""" A_l + ... + A_r が二進数で繰り上がりなし B_l ^ ... ^ B_r が0 ならOK """ n = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) zo = [1, 0] ans = 0 bit = 0 l = 0 X = [0] for b in B: X.append(X[-1] ^ b) for r, (a, b) in enumerate(zip(A, B), 1): while bit & a != 0: bit ^= A[l] zo[X[l]] -= 1 l += 1 bit ^= a zo[X[r]] += 1 ans += zo[X[r]] print(ans - n)