#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;

#define MX 200002
int dp[MX];
void solve()
{
int n,m;
cin>>n>>m;
int arr[n];
for(int i=0;i<n;i++)
    cin>>arr[i];
int pref[n+10]={};

sort(arr,arr+n);
pref[1]=arr[1]-arr[0];
for(int i=3;i<n;i+=2)
{
    pref[i]=arr[i]-arr[i-1];
    pref[i]+=pref[i-2];
}
int suff[n+10]={};
suff[n-2]=arr[n-1]-arr[n-2];
for(int i=n-4;i>=0;i-=2)
{
    suff[i]=arr[i+1]-arr[i];
    suff[i]+=suff[i+2];
}
int cnt=INT_MAX;
for(int i=0;i<m;i++)
{
    int x;
    cin>>x;
    int pos=lower_bound(arr,arr+n,x)-arr;
    int ans=0;
    if(pos%2==0)
    { if(pos!=0)
        ans+=pref[pos-1];
        if(pos<n-1)
        ans+=suff[pos+1];
        ans+=abs(arr[pos]-x);
    }
    else
    {
        ans+=abs(arr[pos-1]-x);
        ans+=suff[pos];
        if(pos-2>=0)
        ans+=pref[pos-2];
    }
   cnt=min(cnt,ans);
}
cout<<cnt<<endl;
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t=1;

while(t--)
{
solve();
}
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a / gcd(a, b) * b; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;


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

    ll n,m,ans = INF;
    cin>>n>>m;
    vector<ll>h(n),w(m);
    rep(i,n)cin>>h[i];
    rep(i,m)cin>>w[i];

    sort(all(h));
    
    vector<int>a((n + 1) / 2,0);
    rep(i,1,n - 1,2){
        a[0] += abs(h[i] - h[i + 1]);
    }
    rep(i,n / 2){
        a[i + 1] = a[i] - abs(h[i * 2 + 1] - h[i * 2 + 2]) + abs(h[i * 2] - h[i * 2 + 1]);
    }

    rep(i,m){
        auto itr = lower_bound(all(h),w[i]);
        int dist = itr - h.begin();
        int p = dist / 2;

        ans = min(ans,a[p] + abs(h[p * 2] - w[i]));
    }
    cout<<ans<<endl;
}
