#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#define ll long long
#define lli long long int
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#include<string>
#include<cctype>
#define F first
#define S second
#include<queue>
#define ii pair<int,int>
#include <sstream>
#define lli long long int
#define pairs pair<int,int>
#define ld long double
#define mod 1000000007
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
ll pows(ll a,ll n,ll m)
{
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll  gcd(ll a,ll b)
{
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
			return false;
			}	
	}
	return true;
}
ll n,m;
vector<ll>a,b;
int main()
{
ios::sync_with_stdio(false);
	 cin.tie(0);
    cout.tie(0);
cin>>n>>m;
ll x;
for(ll i=0;i<n;i++)
{
	cin>>x;
	a.pb(x);
}
for(ll i=0;i<m;i++)
{
cin>>x;
b.pb(x);
}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
vector<ll> diff1(n/2+1),diff2(n/2+1);
for(ll i=0;i<n/2;i++)
{
	diff1[i+1]=diff1[i]+abs(a[2*i+1]-a[2*i]);
	diff2[i+1]=diff2[i]+abs(a[2*i+1]-a[2*i+2]);
}
ll ans=1e18;
for(ll i=0;i<n;i++)
{
	ll temp=0;
	auto it=lower_bound(b.begin(),b.end(),a[i]);
	if(it==b.begin())
	{
		temp=temp+abs(*it-a[i]);
	}
	else if(it==b.end())
	{
		it--;
		temp+=abs(*it-a[i]);
	}
	else
	{
		temp=abs(*it-a[i]);
		it--;
		temp=min(temp,abs(*it-a[i]));
	}
	if(i%2==0)
	{
	temp+=diff1[i/2]+diff2[n/2]-diff2[i/2];	
	}
	else
	{
		temp+=diff1[i/2]+abs(a[i+1]-a[i-1])+diff2[n/2]-diff2[(i/2)+1];
	}
	ans=min(ans,temp);
}
cout<<ans<<endl;
}



 



#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;
	vector<int> H(N), W(M+2);
	rep(i,N){
		cin >> H[i];
	}
	rep(i,M){
		cin >> W[i];
	}
	W[M] = -INF;
	W[M+1] = INF;
	sort(H.begin(), H.end());
	sort(W.begin(), W.end());
	vector<int> dp1(N/2+1), dp2(N/2+1);
	rep(i,N/2){
		dp1[i+1] = H[i*2+1] - H[i*2] + dp1[i];
		dp2[i+1] = H[N-1-i*2] - H[N-2-i*2] + dp2[i];
	}
	reverse(dp2.begin(), dp2.end());
	int ans = INF;
	rep(i,N/2+1){
		int Z = dp1[i] + dp2[i];
		int botti = H[i*2];
		auto itr = lower_bound(W.begin(), W.end(), botti);
		int X = *itr;
		--itr;
		int Y = *itr;
		Z += min(abs(botti - X), abs(botti - Y));
		// cout << Z << endl;
		chmin(ans, Z);
	}
	cout << ans << endl;
	/*
	rep(i,N/2+1){
		cout << dp1[i] << ' ' <<  dp2[i] << endl;
	}
	*/
}