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

def twopoints(coords,velos):
    firstv=velos[0]
    secondv=velos[1]
    firstc=coords[0]
    secondc=coords[1]
    if firstv==secondv:
        return abs(firstc-secondc)
    elif firstv<=0 and secondv<=0:
        if firstv<secondv:
            if firstc<secondc:
                return abs(firstc-secondc)
            elif secondc<firstc:
                return 0
        if firstv>secondv:
            if firstc<secondc:
                return 0
            elif secondc<firstc:
                return abs(firstc-secondc)
    elif firstv>0 and secondv>0:
        if firstv>secondv:
            if firstc>secondc:
                return abs(firstc-secondc)
            elif secondc>firstc:
                return 0
        if firstv<secondv:
            if firstc>secondc:
                return 0
            elif secondc>firstc:
                return abs(firstc-secondc)
    else:
        return abs(firstc-secondc)
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:
    pone=tuple[0]
    ptwo=tuple[1]
    vone=speeds[pone]
    cone=initcoords[pone]
    vtwo=speeds[ptwo]
    ctwo=initcoords[ptwo]
    a=(vone,vtwo)
    b=(cone,ctwo)
    sum+=twopoints(b,a)
print(sum)


        

                


        
    
    




