#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>
//#include<atcoder/all>


using namespace std;
//using namespace atcoder;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.12f\n", x)
const double pi = acos(-1.0);
const ll MOD = 998244353;
const ll INF = 1e18;
const ll MAX_N = 1010101;
void chmin(ll a, ll b) { if (a > b) { a = b; } }
void chmax(ll a, ll b) { if (a < b) { a = b; } }

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// mod.m での a の逆元 a^ { -1 } を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//union-find木について
ll par[201010];
ll rank2[201010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 1;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
		rank2[y] += rank2[x];
	}
	else {
		par[y] = x;
		rank2[x] += rank2[y];
	}
}


ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
bool flag[201010];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n, m;
	cin >> n >> m;
	vector<ll>h(n);
	rep(i, n) {
		cin >> h[i];
	}
	sort(h.begin(), h.end());
	vector<ll>sum1((n + 1) / 2), sum2((n + 1) / 2);

	for (ll i = 0;i+1 < n;i += 2) {
		sum1[i / 2 + 1] = sum1[i / 2] + h[i + 1] - h[i];
	}
	for (ll i = n - 2;i > 0;i -= 2) {
		sum2[i / 2] = sum2[i / 2 + 1] + h[i+1] - h[i];
	}

	ll ans = INF;
	rep(i, m) {
		ll w;
		cin >> w;
		ll x = lower_bound(h.begin(), h.end(), w) - h.begin();
		if (x & 1) x ^= 1;
		ans = min(ans, sum1[x / 2] + sum2[x / 2] + abs(h[x] - w));
	}
	cout << ans << endl;
	return 0;
}
#include<iostream>
#include<algorithm>
using namespace std;
int n,m;
long long a[200010],b[200010],sumq[200010],sumh[200010],ans=1999999999;
int main()
{
     int i,now=0;
     cin>>n>>m;
     for(i=1;i<=n;i++) cin>>a[i];
     for(i=1;i<=m;i++) cin>>b[i];
     sort(a+1,a+n+1);
     sort(b+1,b+m+1);
     for(i=2;i<=n;i+=2) sumq[i]=sumq[i-2]+a[i]-a[i-1];
     for(i=n-1;i>=1;i-=2) sumh[i]=sumh[i+2]+a[i+1]-a[i];
     /*for(i=1;i<=n;i++) cout<<a[i]<<" ";
     cout<<endl;
     for(i=1;i<=m;i++) cout<<b[i]<<" "; 
     cout<<endl;
     for(i=2;i<=n;i++) cout<<sumq[i]<<" "<<sumh[i]<<endl;*/
     for(i=1;i<=m;i++)
     {
         while(b[i]>a[now]&&now<=n) now++;
         if(now%2==1) ans=min(ans,a[now]-b[i]+sumq[now-1]+sumh[now+1]);
         else ans=min(ans,b[i]-a[now-1]+sumq[now-2]+sumh[now]);
     }
     cout<<ans;
     system("pause");
}
