#include <bits/stdc++.h>
#include<random>
using namespace std; typedef unsigned long long _ulong; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define endk '\n'
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; }
lint gcd(lint a, lint b) { if (b == 0) return a; else return gcd(b, a % b); }
lint ceil(lint a, lint b) { return (a + b - 1) / b; }
lint digit(lint a) { return (lint)log10(a); }
const lint MOD = 998244353, INF = 1e18;
lint dx[8] = { 0, -1, 1, 0, 1, -1, 1, -1 }, dy[8] = { 1, 0, 0, -1, -1, -1, 1, 1 };
typedef pair<long double, lint> Pa;
typedef pair<lint, plint> tlint;
struct point {
	lint r;
	lint x, y;
};

lint N, M;
int main() {
	cin >> N >> M;
	vector<lint> arr(N);
	vector<lint> change(M);
	REP(i, N) {
		cin >> arr[i];
	}
	REP(i, M) {
		cin >> change[i];
	}
	sort(ALL(arr));
	vector<lint> sums(N + 1);
	vector<lint> revsums(N + 1);
	REP(i, N / 2) {
		sums[i + 1] = sums[i] + (arr[i * 2 + 1] - arr[i * 2]);
	}
	REP(i, N / 2) {
		revsums[i + 1] = revsums[i] + (arr[N - i * 2 - 1] - arr[N - i * 2 - 2]);
	}
	lint minv = INF;
	REP(i, M) {
		lint idx = lower_bound(ALL(arr), change[i]) - arr.begin();
		if (idx % 2 == 0) {
			chmin(minv, sums[idx / 2] + revsums[N / 2 - idx / 2] + abs(arr[idx] - change[i]));
		}
		else {
			idx--;
			chmin(minv, sums[idx / 2] + revsums[N / 2 - idx / 2] + abs(arr[idx] - change[i]));
		}
	}
	cout << minv << endk;
}
//#undef DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll llinf = (1ll<<61)-1;
#define sz(a) int(a.size())
#define all(x) begin(x), end(x)
#ifdef DEBUG
const int DEBUG_END = 26;
#define DOS cout
#include <debug.h>
#else
#define bug(args...) void()
#define cbug(a, args...)
#endif
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define fi first
#define se second
const int inf = 1000000007, N=200005;
int TC = 1, CN, n, m, h[N], w[N];
ll ps[N];

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    //cin >> TC;// inputAll + resetAll -> solution
    auto kase = [&]()->void {
        cin >> n >> m;
        for (int i = 1; i <= n; i++) {
            cin >> h[i];
        }
        sort(h+1, h+1+n);
        for (int i = 1; i <= n; i++) {
            int o = (i&1 ? -1 : 1)*h[i];
            ps[i] = ps[i-1]+o;
        }
        ll ans = llinf;
        for (int i = 1; i <= m; i++) {
            cin >> w[i];
            int p = int(lower_bound(h+1, h+1+n, w[i])-h);
            ll cur = ps[p-1]+(p&1 ? -1 : 1)*w[i]-(ps[n]-ps[p-1]);
            //bug(cur);
#ifdef DEBUG
            cur = 0;
            vector<int> v(h+1, h+1+n);
            v.push_back(w[i]);
            sort(all(v));
            for (int j = 1; j <= n+1; j++) {
                cur += (j&1 ? -1 : 1)*v[j-1];
            }
            //bug(cur);
#endif
            ans = min(ans, cur);
        }
        cout << ans << '\n';
    };
    while (CN++!=TC) kase();
}