#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=200005;
int n,m,a[N],b[N],s[N],t[N],ans=1e18;
signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=m;i++)
		cin>>b[i];
	sort(b+1,b+m+1);
	for(int i=2;i<=n-1;i+=2)
		s[i]=s[i-2]+abs(a[i]-a[i-1]);
	for(int i=n-1;i>=1;i--)
		t[i]=t[i+2]+abs(a[i]-a[i+1]);
	for(int i=1;i<=n;i++)
	{
		if(i&1)
		{
			int r=s[i-1]+t[i+1];
			int x=lower_bound(b+1,b+m+1,a[i])-b,y=1e18;
			if(x!=m+1) y=min(y,abs(a[i]-b[x]));
			if(x!=1) y=min(y,abs(a[i]-b[x-1]));
			ans=min(ans,r+y);
		}
		else
		{
			int r=(n<=3?0:s[i-2]+t[i+2])+(n<=1?0:abs(a[i-1]-a[i+1]));
			int x=lower_bound(b+1,b+m+1,a[i])-b,y=1e18;
			if(x!=m+1) y=min(y,abs(a[i]-b[x]));
			if(x!=1) y=min(y,abs(a[i]-b[x-1]));
			ans=min(ans,r+y);
		}
	}
	cout<<ans<<endl;
	return 0;
}
#include <bits/stdc++.h>
#define yala ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0);
#define RW freopen("input.txt","r",stdin), freopen("output.txt","w",stdout);
#define ll long long
#define ld long double
using namespace std;
const ll N = 4e5 + 5;
const ll INF = 1e18;
const int mod = 1e9 + 5;
const double pi = 3.1415926536;
int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};
ll dp[N][2][2];
vector<pair<int, int>>v;
ll solve (int i, int sign, int yes) {
    if (i == v.size()) {
        return (!yes) * 1e18;
    }
    ll &val = dp[i][sign][yes];
    if (~val)
        return val;
    if (v[i].second) {
        val = solve(i + 1, sign, yes);
        if (!yes)
            val = min(val, (sign ? v[i].first : -v[i].first) + solve(i + 1, !sign, 1));
    } else
        val = (sign ? v[i].first : -v[i].first) + solve(i + 1, !sign, yes);
    return val;
}
int main() {
    yala;
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        v.push_back({a, 0});
    }
    for (int i = 0; i < m; ++i) {
        int b;
        cin >> b;
        v.push_back({b, 1});
    }
    sort(v.begin(), v.end());
    memset(dp, -1, sizeof dp);
    cout << solve(0, 0, 0) << '\n';
    return 0;
}