#include<bits/stdc++.h>
using namespace std;


int main()
{
	int n, m; cin >> n >> m;
	vector<int> H(n), L((n+1)/2), R((n+1)/2);
	for (int i = 0; i < n; ++i)
		cin >> H[i];
	sort(H.begin(), H.end());
	for (int i = 0; i+1 < n; i+=2)
		L[i/2+1] = L[i/2] + H[i+1] - H[i];
	for (int i = n-2; i >= 0; i-=2)
		R[i/2] = R[i/2+1] + H[i+1] - H[i];
	int ans = INT_MAX;
	for (int i = 0; i < m; ++i)
	{
		int w; cin >> w;
		auto it = lower_bound(H.begin(), H.end(), w) - H.begin();
		if (it & 1) it ^= 1;
		ans = min(ans, L[it/2] + R[it/2] + abs(w - H[it]));
	}
	cout << ans << endl;
}


//#include <tourist>
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//g++ yarudake.cpp -std=c++17 -I .
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    sort(ALL(a));
    sort(ALL(b));
    vector<ll> odd(n), even(n);
    ll sumo = 0;
    ll sume = 0;
    rep(i, n)
    {
        if (i % 2)
        {
            sumo += a[i];
        }
        else
        {
            sume += a[i];
        }
        odd[i] = sumo;
        even[i] = sume;
    }
    //debug(odd);
    //debug(even);
    ll ans = LINF;
    rep(i, n)
    {
        ll sum = 0;
        int x = upper_bound(ALL(b), a[i])-b.begin();
        if (x == 0)
        {
            sum += abs(b[x] - a[i]);
        }
        else if (x == b.size())
        {
            sum += abs(b[x - 1] - a[i]);
        }
        else
        {
            sum += min(abs(b[x] - a[i]), abs(b[x - 1] - a[i]));
        }
        ll plus = 0;
        ll minus = 0;
        if (i % 2)
        {
            minus += even[i - 1];
            minus += odd[n - 1] - odd[i];
            if (i >= 2)
                ;
            plus += odd[i - 2];
            plus += even[n - 1] - even[i - 1];
        }
        else
        {
            if (i >= 2)
                minus += even[i - 2];
            if (i >= 1)
                minus += odd[n - 1] - odd[i - 1];
            else
            {
                minus += odd[n - 1];
            }
            if (i >= 1)
                plus += odd[i - 1];
            plus += even[n - 1] - even[i];
        }
        sum += plus - minus;
        chmin(ans, sum);
    }
    cout << ans << "\n";
}
