#include <bits/stdc++.h>
using namespace std;
int calcdist(int x1, int x2, int v1, int v2) {
  int dist = 0;
  if (x1 == x2)
    return dist;
  else if (x2 > x1) {
    if ((v1 - v2) <= 0)
      return (x2 - x1);
    else
      return dist;
  } else {
    if ((v2 - v1) <= 0)
      return (x1 - x2);
    else
      return dist;
  }
}
int main() {
  int n;
  cin >> n;
  long sum = 0;
  int x[n], v[n];
  for (int i = 0; i < n; i++) cin >> x[i];
  for (int i = 0; i < n; i++) cin >> v[i];
  for (int i = 0; i < (n - 1); i++) {
    for (int j = i + 1; j < n; j++) sum += calcdist(x[i], x[j], v[i], v[j]);
  }
  cout << sum << endl;
  return 0;
}
