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