#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<ll>
#define vll vector<ll> 
#define all(x) (x).begin() , (x).end()
#define inf 1000000000
#define mod 1000000007

void dbg(){
	cerr << endl;
}
template<typename Head , typename... Tail>
void dbg(Head h , Tail... t){
	cerr << h << " ";
	dbg(t...);
}

#ifdef EMBI_DEBUG
#define debug(...) cerr << "(" << #__VA_ARGS__  << "): ", dbg(__VA_ARGS__)
#else 
#define debug(...)
#endif

const ll max_n = 1e5 + 9;

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
void solve(){
	ll n , m;
    cin >> n >> m;

    ll a[n] , b[m];
    for(ll i = 0 ; i < n ; i++)cin >> a[i];
    for(ll i = 0 ; i < m ; i++)cin >> b[i];

    sort(a , a+n);
    sort(b , b+m);

    ll pref[n] , sum = 0;
    for(ll i = n-1 ; i >= 0 ; i--){
        sum += ((n-i) % 2 ? 1 : -1) * a[i];
    }

    ll curr = 0;

    for(ll i = 0 ; i < n ; i++){
        ll new_sum = sum - (i%2==0 ? 1:-1)*a[i];
        pref[i] = new_sum + curr;
        curr += (i % 2 ? 1 : -1) * a[i];
        sum = new_sum;
    }

    // for(ll i = 0 ; i < n ; i++)cout << pref[i] << " ";
    // cout << "\n";

    ll minimum = inf;

    for(ll i = 0 ; i < n ; i++){
        auto it = lower_bound(b , b+m , a[i]) - b;
        ll min1 = inf;
        if(it != m){
            min1 = min(min1 , abs(a[i] - b[it]));
        }
        it--;
        if(it >= 0){
            min1 = min(min1 , abs(a[i] - b[it]));
        }

        minimum = min(minimum , min1 + pref[i]);
    }
    cout << minimum << "\n";
}
signed main(){
	ll t = 1;
	// cin >> t;
	for(ll i = 1 ; i <= t ; i++){
		solve();
	}
}
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 2000000000;
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  REP(i,n) cin >> h[i];
  vector<int> w(m);
  REP(i,m) cin >> w[i];

  // debug(w);
  
  sort(ALL(h));
  sort(ALL(w));
  

  vector<ll> diff1(n/2 + 1);
  vector<ll> diff2(n/2 + 1);

  ll sum = 0;

  //1
  int cc = 1;
  for(int i = 0; i < n-2; i += 2){
   int d = h[i+1] - h[i];
   sum += d;
   diff1[cc] = sum;
   cc++;
  }

  

  //2
  sum = 0;
  cc = 1;
  for(int i = 1; i < n-1; i += 2){
   int d = h[i+1] - h[i];
   sum += d;
   diff2[cc] = sum;
   cc++;
  }

  // debug(diff1);
  // debug(diff2);

  //自身の挿入箇所
  int ans = INF;
  REP(i,m){
    auto pos = lower_bound(ALL(h), w[i]) - h.begin();


    int befsum = INF;
    int aftsum = INF;
    //1 後ろと差分
   if( pos%2 == 0 ){
      ll pre = diff1[(pos)/2];
      ll mid = abs(h[pos] - w[i]);
      ll aft = diff2[n/2] - diff2[(pos)/2];
      aftsum = pre + mid + aft;
      debug(pos);
      debug(pre);
      debug(mid);
      debug(aft);
   }

    //2　前との差分
  if( pos%2 == 1 ){
    ll pre = diff1[(pos)/2];
    ll mid = abs(h[pos-1] - w[i]);
    ll aft = diff2[n/2] - diff2[(pos)/2];
    befsum = pre+mid+aft;
  }

  // debug(aftsum);
  // debug(befsum);

   ans = min({ans, befsum, aftsum});

  }

  cout << ans << endl;

  return 0;
}
