#include <bits/stdc++.h>
using namespace std;
#define rep(i,x,n) for(int i=x;i<(int)n;++i)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define out(a) cout<<a<<endl;
#define vout(v) rep(i,0,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vvout(vv) rep(j,0,vv.size()){vout(vv[j])}
#define mout(m) for(auto&e:m)cout<<e.first<<": "<<e.second<<endl;
#define _CHK_ 1
#define chk(a) if constexpr (_CHK_){cout<<#a<<": ";out(a)}
#define vchk(v) if constexpr (_CHK_){cout<<#v<<": ";vout(v)}
#define vvchk(vv) if constexpr (_CHK_){cout<<#vv<<": "<<endl;vvout(vv)}
#define mchk(m) if constexpr (_CHK_){cout<<#m<<": "<<endl;mout(m)}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    std::vector<long long> W(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&W[i]);
    }
    sort(H.begin(), H.end());
    sort(W.begin(), W.end());
    // vchk(H)
    // vchk(W)

    vector<long long> diff1((N+1)/2);
    vector<long long> diff2((N+1)/2);
    for (long long i = 0; i+1 < (N+1)/2; i++) {
        diff1[i]=H[2*i+1]-H[2*i];
        diff2[i]=H[2*i+2]-H[2*i+1];
    }
    // vchk(diff1)
    // vchk(diff2)

    vector<long long> acc1((N+1)/2);
    vector<long long> acc2((N+1)/2);
    acc1[0]=diff1[0];
    acc2[0]=diff2[0];
    for (long long i = 1; i < (N+1)/2; i++) {
        acc1[i]=acc1[i-1]+diff1[i];
        acc2[i]=acc2[i-1]+diff2[i];
    }
    // vchk(acc1)
    // vchk(acc2)

    long long ret=LLONG_MAX;
    for (long long i = 0; i < M; i++) {
        long long sum=0;
        auto itr = upper_bound(H.begin(), H.end(), W[i]);
        long long pos = itr - H.begin();
        // chk(W[i])
        // chk(pos)
        if(pos%2){
            sum+=W[i]-H[pos-1];
            if(pos/2-1>=0) {
                sum+=acc1[pos/2-1];
            }
            sum+=acc2[(N+1)/2-1];
            if(pos/2-1>=0) {
                sum-=acc2[pos/2-1];
            }
        }else{
            sum+=H[pos]-W[i];
            if(pos/2-1>=0) {
                sum+=acc1[pos/2-1];
            }
            if(pos/2<N/2){
                sum+=acc2[N/2-1];
                if(pos/2-1>=0) {
                    sum-=acc2[pos/2-1];
                }
            }
        }
        ret=min(ret, sum);
    }
    out(ret)

    return 0;
}

#include<bits/stdc++.h>

typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
//mt19937_64 mrand(42);
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl;
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back
#define PS string qqwwee;cin>>qqwwee;

const int maxn = 200005;
ll a[maxn], b[maxn], pre[maxn], suf[maxn];
int main() {
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, m;
    cin >> n >> m;
    ii cin >> a[i];
    sort(a+1, a+1+n);
    for(int i=2;i<=n;++i) pre[i] = pre[i-2] + abs(a[i] - a[i-1]);
    for(int i=n-1;i>=1;--i) suf[i] = suf[i+2] + abs(a[i] - a[i+1]);
    for(int i=1;i<=m;++i) cin >> b[i];
    sort(b+1, b+1+m);
    auto go = [&](int x) -> ll {
        int pos = lower_bound(b+1,b+1+m,x)-b;
        ll ret = 1e18;
        for(int i=max(1,pos-1);i<=min(m,pos+1);++i) ret = min(ret, abs(b[i] - x));
        return ret;
    };
    ll ans = 1e18;
    for(int i=1;i<=n;++i) {
        if(i % 2 == 0) ans = min(ans, pre[i-2] + suf[i+2] + abs(a[i-1] - a[i+1]) + go(a[i]));
        else ans = min(ans, pre[i-1] + suf[i+1] + go(a[i]));
    }
    cout << ans << endl;
}