numberofpoints=int(input())
initcoords=input().split(" ")
speeds=input().split(" ")
initcoords=tuple(map(int,initcoords))
speeds=tuple(map(int,speeds))

def twopoints(coords,velos):
    firstv=velos[0]
    secondv=velos[1]
    firstc=coords[0]
    secondc=coords[1]
    dif=abs(firstv-secondv)
    nextdif=abs((firstc+firstv)-(secondc+secondv))
    if dif>nextdif:
        return 0
    else:
        return dif
lis=[]
for first in range(numberofpoints):
    for second in range(first+1,numberofpoints):
        tup=(first,second)
        lis.append(tup)
sum=0
for tuple in lis:
    a=(speeds[tuple[0]],speeds[tuple[1]])
    b=(initcoords[tuple[0]],initcoords[tuple[1]])
    sum+=twopoints(b,a)
print(sum)


        

                


        
    
    




