for _ in range(1):
    n=int(input())
    a=[int(i) for i in input().split()]
    b=[int(i) for i in input().split()]
    cou=0
    for i in range(n):
        for j in range(i,n):
            if (b[i]==b[j]) or (b[i]<0 and b[j]>0) or (b[i]>0 and b[j]<0) or(b[i]<b[j] and a[i]<a[j]) or(b[i]>b[j] and a[i]>a[j]) :
                cou+=(abs(a[i]-a[j]))
    print(cou)