#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
long long n, ans;
pair<long long, long long> p[N];
int main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    long long x;
    scanf("%lld", &x);
    p[i].first = x;
  }
  for (long long i = 1; i <= n; i++) {
    long long v;
    scanf("%lld", &v);
    p[i].second = v;
  }
  sort(p + 1, p + 1 + n);
  for (long long i = 1; i <= n; i++)
    for (long long j = i + 1; j <= n; j++) {
      long long vi = p[i].second, vj = p[j].second;
      long long xi = p[i].first, xj = p[j].first;
      if (vi * vj > 0) {
        if (vi > vj) ans += 0;
        if (vi < vj) ans += xj - xi;
      }
      if (vi * vj < 0) {
        if (vi > 0 && vj < 0) ans += 0;
        if (vi < 0 && vj > 0) ans += xj - xi;
      }
    }
  printf("%lld", ans);
  return 0;
}
