#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
long long a[200010],b[200010];
int n,m;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i) scanf("%lld",&a[i]);
	for(int i=1;i<=m;++i) scanf("%lld",&b[i]);
	sort(a+1,a+1+n);
	sort(b+1,b+1+m);
	
	long long l=0,r=0;
	for(int i=n;i>=2;i-=2){
		r+=a[i]-a[i-1];
	}
	long long ans=1e18;
	for(int i=1;i<=n;i+=2){
		int p=lower_bound(b+1,b+1+m,a[i])-b;
		if(p!=m+1) ans=min(ans,r+l+b[p]-a[i]);
		if(p!=1) ans=min(ans,r+l+a[i]-b[p-1]);
		l+=a[i+1]-a[i];
		r-=a[i+2]-a[i+1];
	}
	cout<<ans<<endl;
	return 0;
}
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < n; i++)

int main() {
    int n, m;   cin >> n >> m;
    vector<ll> h(n), w(m);
    rep(i, n)   cin >> h[i];
    rep(i, m)   cin >> w[i];
    sort(h.begin(), h.end());
    sort(w.begin(), w.end());

    vector<ll> s1(n/2+1, 0), s2(n/2+1, 0);
    rep(i, n/2) {
        s1[i+1] = s1[i] + abs(h[2*i]-h[2*i+1]);
    }
    rep(i, n/2) {
        s2[i+1] = s2[i] + abs(h[2*i+1]-h[2*i+2]);
    }
    /*
    rep(i, n/2+1)
        cout << s1[i] << " ";
    cout << endl;
    rep(i, n/2+1)
        cout << s2[i] << " ";
    cout << endl;
    */
    
    ll ans = 1e18;
    rep(i, m) {
        auto ite = lower_bound(h.begin(), h.end(), w[i]);
        int j = ite - h.begin();
        ll tmp;
        if (ite == h.end()) {
            tmp = w[i] - h[n-1] + s1[n/2];
        }
        if (j % 2) {
            tmp = abs(w[i]-h[j-1]) + s1[(j-1)/2] - s1[0] + s2[n/2] - s2[(j-1)/2];
            ans = min(tmp, ans);
        }
        else {
            if (j > 0) {
                tmp = s1[j/2] - s1[0] + abs(h[j]-w[i]) + s2[n/2] - s2[j/2];
                ans = min(ans, tmp);
            }
            else {
                tmp = abs(h[0]-w[i]) + s2[n/2] - s2[0];
                ans = min(tmp, ans);
            }
        }   
        //cout << tmp << endl;
    }

    cout << ans << endl;
    return 0;
}

//小数点精度
//cout << fixed << std::setprecision(15) << y << endl;