n = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) cnt = 0 for l in range(1, 40): for i in range(n - l + 1): x = a[i:i + l] y = b[i:i + l] n1 = 0 n2 = 0 n3 = 0 for v in x: n1 += v n2 ^= v for v in y: n3 ^= v if n1 - n2 == n3: cnt += 1 print(cnt)