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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    lint N, M;
    cin >> N >> M;
    lint P = (N + 1) / 2;
    vector<lint> H(N), W(M);
    rep(i, N) { cin >> H[i]; }
    rep(i, M) { cin >> W[i]; }
    sort(all(H));
    sort(all(W));

    lint odd = 0, even = 0;
    vector<lint> L_odd(N + 100, 0), L_even(N + 100, 0);
    rep(i, N) {
        if (i % 2 == 0) {
            L_even[i + 1] = L_even[i] + H[i];
            L_even[i + 2] = L_even[i] + H[i];
        } else {
            L_odd[i + 1] = L_odd[i] + H[i];
            L_odd[i + 2] = L_odd[i] + H[i];
        }
    }
    rep(i, N) {
        if (i % 2 == 0) {
            even += H[i];
        } else {
            odd += H[i];
        }
    }

    lint mi = LINF;
    for (int k = 0; k < M; k++) {
        lint add = W[k];
        int i    = upper_bound(all(H), add) - H.begin();

        // dd(add, i);
        // dd(L_odd[i], L_even[i]);
        // dd((even - L_even[i]), (odd - L_odd[i]));
        lint tmp;
        if (i % 2 == 1) {
            tmp = (L_odd[i] - L_even[i]) + add;
            // d(tmp);
            tmp += (even - L_even[i]) - ((odd - L_odd[i]));
        } else {
            tmp = (L_odd[i] - L_even[i]) - add +
                  ((even - L_even[i]) - (odd - L_odd[i]));
        }
        // d(tmp);
        if (tmp <= mi) { mi = tmp; }
    }

    cout << mi << endl;
    // dump(H);
    // dump(W);
    // dump(L_odd);
    // dump(L_even);
    return 0;
}
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N,M;
long H[2<<17];
long L[2<<17],R[2<<17];
main()
{
	cin>>N>>M;
	for(int i=0;i<N;i++)cin>>H[i];
	H[N]=H[N+1]=-2e9;
	H[N+2]=H[N+3]=2e9;
	N+=4;
	sort(H,H+N);
	for(int i=2;i<N;i+=2)
	{
		L[i]=L[i-2]+H[i-1]-H[i-2];
	}
	for(int i=N-2;i>0;i-=2)
	{
		R[i]=R[i+2]+H[i+1]-H[i];
	}
	long ans=1e18;
	for(int i=0;i<M;i++)
	{
		int W;cin>>W;
		int id=lower_bound(H,H+N,W)-H;
		if(id%2==0)
		{
			ans=min(ans,L[id]+H[id]-W+R[id+1]);
		}
		else
		{
			ans=min(ans,L[id-1]+W-H[id-1]+R[id]);
		}
	}
	cout<<ans<<endl;
}
