#include <bits/stdc++.h>
using namespace std;
using LL = long long int;

template <class T>
struct Binary_Indexed_Tree {
    int maxSize;
    T* data;
    Binary_Indexed_Tree(int init_Size) : maxSize(init_Size) {
        data = new T[maxSize + 5];
        memset(data, 0, sizeof(T) * (maxSize + 5));
    }
    ~Binary_Indexed_Tree() { delete[] data; }
    void add(int loc, T val) {
        while (loc < maxSize) {
            data[loc] += val;
            loc += (loc & (-loc));
        }
        return;
    }
    T query(int loc) {
        T ans = 0;
        while (loc > 0) {
            ans += data[loc];
            loc -= (loc & (-loc));
        }
        return ans;
    }
};

struct point {
    LL x, v;
    point(LL x_ = 0, LL v_ = 0) : x(x_), v(v_) {}
    bool operator<(const point& b) { return x < b.x; }
};

const int maxn = 2e5 + 5;
point p[maxn];
int n = 0, v[maxn];

int main(void) {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        scanf("%lld", &p[i].x);
    for (int i = 0; i < n; ++i) {
        scanf("%lld", &p[i].v);
        v[i] = p[i].v;
    }
    sort(p, p + n);
    sort(v, v + n);
    int cnt = unique(v, v + n) - v;
    auto getid = [=](LL val) { return lower_bound(v, v + cnt, val) - v + 1; };
    Binary_Indexed_Tree<LL> c(n);
    Binary_Indexed_Tree<LL> x(n);
    LL ans = 0;
    for (int i = 0; i < n; ++i) {
        LL id = getid(p[i].v);
        LL cnt = c.query(id);
        LL sum = x.query(id);
        ans += (cnt * p[i].x - sum);
        c.add(id, 1);
        x.add(id, p[i].x);
    }
    printf("%lld", ans);
    return 0;
}