N=int(input()) A=list(map(int,input().split())) B=list(map(int,input().split())) ANS=0 now=0 for i in range(N-1): if A[i+1]-A[i]>abs(B[i+1]-B[i]): now+=1 else: ANS+=now*(now+1)//2 now=0 ANS+=now*(now+1)//2 print(ANS)