#include <bits/stdc++.h>
// #include <atcoder/all>
// #include "icld.cpp"
using namespace std;
using ll = long long int;
using pii = pair<int,int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using ss = string;
using db = double;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
#define V vector
#define pi 3.14159265358979
#define rep(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define ci(x) cin >> x
#define cii(x) int x;cin >> x
#define cci(x,y) int x,y;cin >> x >> y
#define co(x) cout << x << endl
void chmax(int &x,int y){x=max(x,y);}
void chmin(int &x,int y){x=min(x,y);}

int main(){
  cci(n,m);
  int n2=n/2;
  
  vi mi(n2),ma(n2),v(n);
  rep(i,0,n)ci(v[i]);
  sort(all(v));

  vi tc(m);
  rep(i,0,m)ci(tc[i]);
  sort(all(tc));

  rep(i,0,n-1)(i%2?ma:mi)[i/2]=v[i+1]-v[i];

  vi smi(n2+1,0),sma(n2+1,0);
  rep(i,0,n2)smi[i+1]=smi[i]+mi[i];
  rep(i,0,n2)sma[n2-i-1]=sma[n2-i]+ma[n2-i-1];

  int ans=1001001001;
  rep(i,0,m){
    int nx=(lower_bound(all(v),tc[i])-v.begin())/2;
    chmin(ans,smi[nx]+abs(v[nx*2]-tc[i])+sma[nx]);
  }
  co(ans);  
}
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ull unsigned long long
#define mp make_pair

void solve()
{
   ll n,m;
   cin>>n>>m;

   vector<ll>v(n);
   ll i,j;
   for(i=0;i<n;i++)cin>>v[i];

   sort(v.begin(),v.end());

   vector<ll>form(m);

   for(i=0;i<m;i++)cin>>form[i];
   sort(form.begin(),form.end());

   vector<ll>dp_left(n+1,0);
   ll prev = 0;
   for(i=1;i<n;i=i+2)
   {
      dp_left[i] = prev+ (v[i] - v[i-1]);
      prev = dp_left[i];
   }
   prev = 0;
   vector<ll>dp_right(n+1,0);

   for(i=n-2;i>=0;i=i-2)
   {
       dp_right[i] = prev + (v[i+1]-v[i]);
       prev = dp_right[i];
   }



   ll val = LLONG_MAX;

   for(i=0;i<=n;i++)
   {
       ll low_index,high_index;
       ll left_index, right_index;
       ll diff_index;
       ll low,high;

       if(i%2==0)
       {
           low_index = i-1;
           high_index = i;
           left_index = i-1;
           right_index = i+1;
           diff_index = i;
       }
       else
       {
           low_index = i-1;
           high_index = i;
           left_index = i-2;
           right_index = i;
           diff_index = i-1;
       }

       ll left_max,right_max;
       if(left_index <0)
       {
           left_max = 0;
       }
       else
       {
           left_max = dp_left[left_index];
       }
       if(right_index>=n)
       {
           right_max = 0;
       }
       else
       {
           right_max = dp_right[right_index];
       }

       if(low_index<0)
       {
           low = INT_MIN;
       }
       else
       {
           low = v[low_index];
       }
       if(high_index>=n)
       {
           high = INT_MAX;
       }
       else
       {
           high = v[high_index];
       }

       ll ans = INT_MAX;

       //cout<<low<<" "<<high<<endl;
       //cout<<diff_index<<endl;

       if(i%2==0)
       {
           ll ub = upper_bound(form.begin(),form.end(),high)-form.begin();
           ub--;
           if(ub<form.size() && ub>=0)
           {
               ans = min(ans, abs(v[diff_index] - form[ub]));
           }
       }
       else
       {
           ll lb = lower_bound(form.begin(),form.end(),low)-form.begin();
           if(lb<form.size() && lb>=0)
           {
               ans = min(ans, abs(v[diff_index] - form[lb]));
           }
       }
       //cout<<ans<<endl;
       ans +=left_max;
       ans += right_max;
       //cout<<ans<<endl;
       val = min(ans, val);
   }
   cout<<val<<endl;





}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t =1;

    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}
