from sys import stdin n = int(stdin.readline().rstrip()) a = [int(x) for x in stdin.readline().rstrip().split()] b = [int(x) for x in stdin.readline().rstrip().split()] bitruiseki = [[0 for i in range(30)] for j in range(n+1)] for i in range(n): val = a[i] for j in range(30): if val & 1: bitruiseki[i+1][j] = bitruiseki[i][j] + 1 else: bitruiseki[i+1][j] = bitruiseki[i][j] val = val >> 1 bxor = [0 for i in range(n+1)] for i in range(n): bxor[i+1] = bxor[i] ^ b[i] bxornum = [0 for i in range(n+1)] for i in range(n): bxornum[i+1] = bxornum[i] + bxor[i] left = 1 ans = 0 for i in range(1,n+1): check = False for j in range(30): if bitruiseki[i][j] - bitruiseki[left-1][j] >= 2: check = True break while check: left += 1 check = False for j in range(30): if bitruiseki[i][j] - bitruiseki[left-1][j] >= 2: check = True break if bxor[i] == 1: ans += bxornum[i] - bxornum[left-1] else: ans += i - left + 1 - (bxornum[i] - bxornum[left-1]) print("{}".format(ans))