#include <bits/stdc++.h>
using namespace std;
int main() {
  int sum = 0;
  int n;
  cin >> n;
  float x[n], u[n];
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> u[i];
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; j++) {
      if (x[i] < x[j]) {
        if (u[i] >= 0 && u[j] >= 0) {
          if (u[j] >= u[i]) sum += x[j] - x[i];
        } else if (u[i] <= 0 && u[j] >= 0)
          sum += x[j] - x[i];
        else if (u[i] <= 0 && u[j] <= 0) {
          if (abs(u[i]) >= abs(u[j])) sum += x[j] - x[i];
        }
      } else if (x[i] > x[j]) {
        if (u[i] >= 0 && u[j] >= 0) {
          if (u[i] >= u[j]) sum += x[i] - x[j];
        } else if (u[i] >= 0 && u[j] <= 0)
          sum += x[i] - x[j];
        else if (u[i] <= 0 && u[j] <= 0) {
          if (abs(u[i]) <= abs(u[j])) sum += x[i] - x[j];
        }
      }
    }
  }
  cout << sum << endl;
}
