#include <bits/stdc++.h>
using namespace std;
double movingPt(double x[], double v[], int j) {
  double d = 0;
  for (int g = 0; g < j - 1; g++) {
    for (int h = g + 1; h < j; h++) {
      if (v[g] == v[h]) {
        d += abs(x[g] - x[h]);
        continue;
      } else if (x[g] > x[h] and v[h] - v[g] > 0) {
        d += 0;
        continue;
      } else if (x[g] < x[h] and v[g] - v[h] > 0) {
        d += 0;
      } else {
        d += abs(x[g] - x[h]);
      }
    }
  }
  return d;
}
int main() {
  int j;
  cin >> j;
  double x[j], v[j];
  for (int g = 0; g < j; g++) {
    cin >> x[g];
  }
  for (int g = 0; g < j; g++) {
    cin >> v[g];
  }
  cout << movingPt(x, v, j);
  return 0;
}
