// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 11/01/20 20:25:34
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);

  int n,m; cin>>n>>m;
  vector<int> H(n); for (auto& h:H) cin>>h;
  vector<int> W(m); for (auto& w:W) cin>>w;
  int u = n/2;

  sort(H.begin(), H.end());
  vector<ll> se(u), so(u);
  for (int i = 0; i < n-1; i++) {
    if (i % 2 == 0) {
      se[i/2] = H[i+1]-H[i];
    } else {
      so[i/2] = H[i+1]-H[i];
    }
  }
  for (int i = 1; i < u; i++)
    se[i] += se[i-1];
  for (int i = u-2; i >= 0; i--)
    so[i] += so[i+1];

  sort(W.begin(), W.end());
  int wi = -1;
  ll ans = 1e18;
  for (auto w:W) {
    while (wi+1 < n and w >= H[wi+1])
      wi++;
    if (wi%2 != 0) {
      ll sum = ((wi-1)/2 >= 0 ? se[(wi-1)/2] : 0);
      sum += H[wi+1]-w;
      sum += ((wi+2)/2 < u ? so[(wi+2)/2] : 0);
      ans = min(ans, sum);
    } else {
      ll sum = ((wi-2)/2 >= 0 ? se[(wi-2)/2] : 0);
      sum += w-H[wi];
      sum += ((wi+1)/2 < u ? so[(wi+1)/2] : 0);
      ans = min(ans, sum);
    }
  }
  cout << ans << endl;

  return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<=b;i++)
inline ll r() {
	ll x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))x=x*10+c-'0',c=getchar();
	return x*f;
}
#define d r()
ll a,b,c;
int main(){
	a=d,b=d,c=d;
	printf("%lld",((a*(a+1)/2)%998244353)*((b*(b+1)/2)%998244353)%998244353*((c*(c+1)/2)%998244353)%998244353);
	return 0;
}