N = int(input()) A = list(map(int, input().split())) + [0] B = list(map(int, input().split())) + [0] ans = 0 for i in range(N + 1): if i == 0: nowa = A[i] + B[i] nowb = A[i] - B[i] cnt = 1 else: nexta = A[i] + B[i] nextb = A[i] - B[i] if nowa < nexta and nowb < nextb: cnt += 1 else: ans += (cnt - 1) * cnt // 2 cnt = 1 nowa = nexta nowb = nextb print(ans)