n=int(input())
x=list(map(int,input().split()))
v=list(map(int,input().split()))
l=[]
for i in range(n):
    l.append((x[i],v[i]))
l.sort()
#print(*l)
ans=0
for i in range(n):
    for j in range(i+1,n):
        if l[i][1]>=0 and l[j][1]>=0:
            if l[i][1]<=l[j][1]:
                ans+=(l[j][0]-l[i][0])
        elif l[i][1]<=0 and l[j][1]<=0:
            if l[j][1]>=l[i][1]:
                ans+=(l[j][0]-l[i][0])

        else:
            ans+=(l[j][0]-l[i][0])
print(ans)
