//----AUTHOR:developer.eeshan----/
#include <bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define it(a, x) for (auto &a : x)
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vs vector<string>
#define gi greater<int>
#define vc vector<char>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvc vector<vc>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int> >
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)
#define deb(x) cout << #x << "=" << x << endl;
#define in(i, n) for (auto i = 0; i < n; i++)
#define all(a) begin(a), end(a)
#define rall(a) rbegin(a), rend(a)
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());  //random shuffler
ll fxp(ll a, ll b) {
    a %= mod;
    ll res = 1;
    while (b > 0) {
        if (b % 2 == 1)
            res = (res * a) % mod;
        a = (a * a) % mod;
        b /= 2;
    }
    return res % mod;
}

inline ll minv(ll x) { return fxp(x, mod - 2); }
inline ll mmul(ll a, ll b) {
    if (a >= mod) a = a % mod;
    if (b >= mod) b = b % mod;
    if (a * b >= mod) return (a * b) % mod;
    return (a * b);
}
inline ll madd(ll a, ll b) {
    if (a >= mod) a = a % mod;
    if (b >= mod) b = b % mod;
    if (a + b >= mod) return (a + b) % mod;
    return (a + b);
}
inline ll msub(ll a, ll b) {
    if (a >= mod) a = a % mod;
    if (b >= mod) b = b % mod;
    return (((a - b) % mod + mod) % mod);
}
inline ll mdiv(ll a, ll bb) {
    if (a >= mod) a = a % mod;
    ll b = minv(bb);
    if (b >= mod) b = b % mod;
    if (a * b >= mod) return (a * b) % mod;
    return (a * b);
}

void c_p_c() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
}

const int mXn = 2e5 + 5;
int n, m, h[mXn], w[mXn], o[mXn], e[mXn];

void solve() {
    cin >> n >> m;
    in(i, n)cin >> h[i];
    in(i, m)cin >> w[i];
    sort(h, h + n);
    //in(i, n)cout << h[i] << ' ';
    //cout << endl;
    o[1] = h[1] - h[0];
    for (int i = 3; i < n; i += 2) o[i] = o[i - 2] + (h[i] - h[i - 1]);
    for (int i = 2; i < n; i += 2) e[i] = e[i - 2] + (h[i] - h[i - 1]);
    ll ans = 1e15;
    in(i, m) {
        int pos = upper_bound(h, h + n, w[i]) - h - 1;
        //pos=-1, pos=n-1
        //cout << "for " << w[i] << " pos is " << pos;
        ll cans = 0;
        if (pos == -1) {
            cans += e[n - 1] + (h[0] - w[i]);
        } else if (pos == n - 1) {
            cans += o[n - 2] + (w[i] - h[n - 1]);
        } else {
            if (pos % 2 == 1)
                pos++;
            cans += abs(w[i] - h[pos]) + o[pos - 1] + (e[n - 1] - e[pos]);
        }
        //cout << " cans is: " << cans << endl;
        ans = min(ans, cans);
    }
    cout << ans;
}

int main(int argc, char const *argv[]) {
    c_p_c();
    solve();
    return 0;
}
// E - Transformable Teacher
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n, m; cin>>n>>m;
	vector<int> H(n), W(m), evn(1), odd(1); // 偶・奇数番目の累積和
	for(int& x:H) cin>>x;
	for(int& x:W) cin>>x;
	sort(H.begin(), H.end());

	for(int i=0; i<n-1; ++i){
		int d = H[i+1] - H[i];
		if(i%2) odd.push_back(odd.back() + d);
		else evn.push_back(evn.back() + d);
	}

	int64_t ans = LLONG_MAX;
	for(int w:W){
		int r = upper_bound(H.begin(), H.end(), w) - H.begin();
		int i = r / 2;
		r -= r%2;
		ans = min(ans, (int64_t)evn[i] + abs(w - H[r]) + odd.back() - odd[i]);
	}
	cout<< ans <<endl;
}
