#include<bits/stdc++.h>
using namespace std;
#define rep(i, N) for(int i = 0; i< N; i++)
typedef long long ll;

int main() {
    int n, m; cin >> n >> m;
    vector<int> h(n), w(m);
    rep(i, n) cin >> h[i];
    rep(i, m) cin >> w[i];
    sort(h.begin(), h.end());
    sort(w.begin(), w.end());
    //左詰での身長差の累積和と右詰での累積和
    vector<int> left, right;
    int lsum = 0, rsum = 0;
    int ans = 1001001001;
    if(h.size() == 1) {
        auto it = lower_bound(w.begin(), w.end(), h[0]);
        int idx = it - w.begin();
        if(it == w.end()) {
            idx = w.size()-1;
        }
        if(idx == 0) {
            ans = abs(h[0] - w[idx]);
        } else {
            ans = min(abs(h[0] - w[idx]), abs(h[0] - w[idx-1]));
        }
        cout << ans << endl;
        return 0;
    }
    for(int i = 0; i < n-1; i += 2) {
        lsum += h[i+1] - h[i];
        rsum += h[i+2] - h[i+1];
        left.push_back(lsum);
        right.push_back(rsum);
    }
    for(int i = 0; i < n; i += 2) {
        int tmp;
        if(i == 0) {
            tmp = right.back();
        }
        else tmp = left[i/2-1] + right.back() - right[i/2-1];
        //先生の分を足す
        auto it = lower_bound(w.begin(), w.end(), h[i]);
        int idx = it - w.begin();
        if(it == w.end()) {
            idx = w.size()-1;
        }
        if(idx == 0) {
            tmp += abs(h[i] - w[idx]);
        } else {
            tmp += min(abs(h[i] - w[idx]), abs(h[i] - w[idx-1]));
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}
#include <bits/stdc++.h>
typedef long long LL;
#define lowbit(x) (x & (-x))

const LL inf  = 1e17+9;
const LL mod  = 1e9+7;
const LL maxn = 2e5+8;

LL n, m, h[maxn], w[maxn], sa[maxn], sb[maxn];

void solve() {
    LL i, j, ans = inf;
    scanf("%lld%lld", &n, &m);
    for (i = 1; i <= n; i++) scanf("%lld", &h[i]);
    for (i = 1; i <= m; i++) scanf("%lld", &w[i]);
    std::sort(h + 1, h + 1 + n);
    for (i = 2; i <= n; i += 2) sa[i] = sa[i - 2] + h[i] - h[i - 1];
    for (i = n - 1; i >= 1; i -= 2) sb[i] = sb [i + 2] + h[i + 1] - h[i];
    for (i = 1; i <= m; i++) {
        LL pos = std::lower_bound(h + 1, h + 1 + n, w[i]) - h;
        if (pos == 0) ans = std::min(ans, sb[2] + abs(h[1] - w[i]));
        else if (pos & 1) ans = std::min(ans, sa[pos - 1] + sb[pos + 1] + abs(h[pos] - w[i]));
        else ans = std::min(ans, sa[pos - 2] + sb[pos] + abs(h[pos - 1] - w[i]));
    }
    printf("%lld\n", ans);
}

signed main() {
    LL t = 1; //scanf("%lld", &t);
    while (t--) solve();
    return 0;
}

