#include <bits/stdc++.h>
using namespace std;
using u64 = unsigned long long;
struct Solution {
  int n;
  vector<int> x, v;
  Solution(int n) : n(n), x(n), v(n) {
    for (int i = 0; i < n; ++i) {
      cin >> x[i];
    }
    for (int i = 0; i < n; ++i) {
      cin >> v[i];
    }
  }
  void solve() {
    u64 sum = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = i + 1; j < n; ++j) {
        int dx = x[j] - x[i], dv = v[j] - v[i];
        if (dx * dv < 0) {
          sum += 0;
        } else {
          sum += abs(dx);
        }
      }
    }
    cout << sum << endl;
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
  int T = 1;
  for (int i = 0; i < T; ++i) {
    int n, m;
    cin >> n;
    Solution(n).solve();
  }
  return 0;
}
