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