#include <bits/stdc++.h>
using namespace std;
int dist(int p1, int p2, int v1, int v2) {
  if ((p1 - p2) * (v2 - v1) > 0)
    return 0;
  else
    return abs(p1 - p2);
}
int main() {
  int n;
  scanf("%d", &n);
  int *pos = (int *)calloc(sizeof(int), n);
  int *vel = (int *)calloc(sizeof(int), n);
  for (int i = 0; i < n; i++) scanf("%d", &pos[i]);
  for (int i = 0; i < n; i++) scanf("%d", &vel[i]);
  long long int sum = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      sum = sum + dist(pos[i], pos[j], vel[i], vel[j]);
    }
  }
  printf("%d", sum);
  return 0;
}
