#include <bits/stdc++.h>
using namespace std;
template <typename type>
void merge_sort(int start, int last, type array, type swap);
long long fn();
int compress(pair<int, int> array[], int k);
pair<int, int> arr1[100009], arr2[100009], help[100009];
bool flag;
int m, n;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &arr1[i].first);
  for (int i = 0; i < m; i++) scanf("%d", &arr2[i].first);
  printf("%lld\n", fn());
  return 0;
}
long long fn() {
  flag = 1, merge_sort(0, n - 1, arr1, help);
  flag = 0, merge_sort(0, m - 1, arr2, help);
  n = compress(arr1, n);
  m = compress(arr2, m);
  long long with1 = arr1[0].second, first = arr1[0].first;
  long long with2 = arr2[0].second, sec = arr2[0].first;
  long long left = arr1[0].first - arr2[0].first, ret = 0;
  int i1 = 1, i2 = 1;
  while (left < 0) {
    if (with1 < with2) {
      if (i1 < n) {
        long long tmp = min(abs(left), abs(arr1[i1].first - first));
        left += tmp;
        ret += with1 * tmp;
        first = arr1[i1].first, with1 += arr1[i1].second;
        i1++;
      } else {
        ret += with1 * abs(left);
        break;
      }
    } else {
      if (i2 < m) {
        long long tmp = min(abs(left), abs(arr2[i2].first - sec));
        left += tmp;
        ret += with2 * tmp;
        sec = arr2[i2].first, with2 += arr2[i2].second;
        i2++;
      } else {
        ret += with2 * abs(left);
        break;
      }
    }
  }
  return ret;
}
int compress(pair<int, int> array[], int k) {
  int i = 0, prev = array[0].first, j = 0, tmp = 0;
  while (i < k) {
    if (array[i].first != prev) {
      array[j].first = prev;
      array[j].second = tmp, j++;
      tmp = 1;
      prev = array[i].first;
    } else
      tmp++;
    i++;
  }
  array[j].first = prev;
  array[j].second = tmp, j++;
  return j;
}
template <typename type>
void merge_sort(int start, int last, type array, type swap) {
  if (last <= start) return;
  int middle = (last - start) / 2;
  middle = start + middle;
  merge_sort(start, middle, array, swap);
  merge_sort(middle + 1, last, array, swap);
  int p1 = start;
  int p2 = middle + 1;
  int main_p = start;
  for (int i = start; i <= middle; i++) swap[i] = array[i];
  while (main_p <= last) {
    if (p1 > middle)
      array[main_p] = array[p2], p2++;
    else if (p2 > last)
      array[main_p] = swap[p1], p1++;
    else if ((swap[p1].first < array[p2].first && flag) ||
             (swap[p1].first > array[p2].first && !flag))
      array[main_p] = swap[p1], p1++;
    else
      array[main_p] = array[p2], p2++;
    main_p++;
  }
  return;
}
