def Gauss(n): return n * (n + 1)//2 N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) ans, cnt = 0, 0 for i in range(N - 1): if A[i + 1] - A[i] > B[i + 1] - B[i]: cnt += 1 else: ans += Gauss(cnt) cnt = 0 ans += Gauss(cnt) print(ans)