#include<bits/stdc++.h>
#include<math.h>
#define ll long long
using namespace std;
const int maxn=2e5+5;
#define INF 1e18+5 

int n,m;
ll a[maxn];
ll sum1[maxn],sum2[maxn];

int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    	scanf("%lld",&a[i]);
    sort(a+1,a+1+n);
    for(int i=2;i<=n;i+=2)
    	sum1[i]=sum1[i-2]+abs(a[i]-a[i-1]);
	for(int i=n-1;i>=1;i-=2)
    	sum2[i]=sum2[i+2]+abs(a[i+1]-a[i]);
    ll ans=INF;
    for(int i=1;i<=m;i++){
    	ll x;
		scanf("%lld",&x);
		int p=lower_bound(a+1,a+1+n,x)-a;
		if(p%2==0)//插入偶数位置
			p--;
		ans=min(ans,sum1[p-1]+sum2[p+1]+abs(a[p]-x));
    }
    printf("%lld\n",ans);
    return 0;
}
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pi pair<int,int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout << #x << ": " << x << endl
#define clr(x,v) memset(x, v, sizeof(x))
#define dblout(x) cout << setprecision(x) << fixed;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int MAXN = 1e6 + 5;

void cp()
{
    int n, m;
    cin >> n >> m;
    vector<ll> arr(n), w(m);
    for(ll &x : arr)
        cin >> x;
    for(ll &x : w)
        cin >> x;
    
    sort(all(arr));
    vector<ll> odd(n), even(n);
    for(int i = 0; i < n; i++)
    {
        if(i & 1)
            odd[i] += arr[i];
        else
            even[i] += arr[i];
        odd[i] += (i ? odd[i - 1] : 0);
        even[i] += (i ? even[i - 1] : 0);
    }

    ll ans = LLONG_MAX;
    for(int i = 0; i < m; i++)
    {
        int lo = 0, hi = n - 1;
        int pos = -1;
        while(lo <= hi)
        {
            int mid = (lo + hi) >> 1;
            if(arr[mid] <= w[i])
                pos = mid, lo = mid + 1;
            else
                hi = mid - 1;
        }
        ll o = (~pos ? odd[pos] : 0);
        ll e = (~pos ? even[pos] : 0);
        pos++;
        if(pos < n)
            o += even[n - 1] - (pos ? even[pos - 1] : 0);
        if(pos < n)
            e += odd[n - 1] - (pos ? odd[pos - 1] : 0);
        if(pos & 1)
            o += w[i];
        else
            e += w[i];
        ans = min(ans, o - e);
    }
    cout << ans << endl;
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}