#include<bits/stdc++.h>

int main(){
    using namespace std;
    const auto scan{[]{unsigned long r; cin >> r; return r;}};
    const auto N{scan()}, M{scan()};
    const auto [h, dif]{[&N]{
        vector<unsigned long> h(N);
        for(auto&& i : h)cin >> i;
        sort(begin(h), end(h));
        vector<unsigned long> rp{0}, ra;
        for(unsigned long i{0}; i + 1 < N; i += 2)rp.push_back(h[i + 1] - h[i]);
        for(unsigned long i{1}; i + 1 < N; i += 2)ra.push_back(h[i + 1] - h[i]);
        ra.push_back(0);
        partial_sum(begin(rp), end(rp), begin(rp));
        partial_sum(rbegin(ra), rend(ra), rbegin(ra));
        transform(begin(rp), end(rp), begin(ra), begin(rp), plus<>{});
        return make_pair(h, rp);
    }()};
    const auto w{[&M]{
        vector<unsigned long> w(M);
        for(auto&& i : w)cin >> i;
        sort(begin(w), end(w));
        return w;
    }()};
    auto it{begin(h)};
    unsigned long ans{numeric_limits<unsigned long>::max()};
    for(const auto& i : w){
        while(it != end(h) && i > *it)++it;
        const unsigned long idx{(it - begin(h)) / 2UL};
        ans = min(dif[idx] + max(h[2 * idx], i) - min(h[2 * idx], i), ans);
    }
    cout << ans << endl;
    return 0;
}

#pragma region Region_1

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
using ll = long long;
using P = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VP = vector<P>;
#define MOD 1000000007
const int INF = 1e9 + 10;

template <class T, class C>
void chmax(T& a, C b) {
    if (a <= b) a = b;
}
template <class T, class C>
void chmin(T& a, C b) {
    if (a >= b) a = b;
}

template <class T>
T sum(const vector<T>& v) {
    T res = 0;
    for (size_t i = 0; i < v.size(); ++i) res += v[i];
    return res;
}

/////////////////////////////////////////////////////////
// print like python
// https://qiita.com/Lily0727K/items/06cb1d6da8a436369eed
/////////////////////////////////////////////////////////
void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << " ";
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T>& vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << " ";
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>>& df) {
    for (auto& vec : df) {
        print(vec);
    }
}

#pragma endregion Region_1
/////////////////////////////////////////////////////////

int main() {
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    std::cout << std::setprecision(15);
    //////////////////////////////////////////

    int n, m;
    cin >> n >> m;
    VL H(n);
    VL W(m);

    rep(i, n) cin >> H[i];
    rep(i, m) cin >> W[i];

    sort(rng(H));

    VL sum1(n + 1, 0);
    for (int i = 0; i < n - 1; i += 2) {
        sum1[i / 2 + 1] = sum1[i / 2] + H[i + 1] - H[i];
    }

    VL sum2(n + 1, 0);
    for (int i = n - 2; i > 0; i -= 2) {
        sum2[i / 2] = sum2[i / 2 + 1] + H[i + 1] - H[i];
    }

    ll ans = 2 * INF;
    rep(i, m) {
        ll w = W[i];
        ll idx = [&] {
            int l = -1, r = n;
            while (l + 1 < r) {
                int m = (l + r) / 2;
                if (H[m] < w) {
                    l = m;
                } else {
                    r = m;
                }
            }
            return r;
        }();
        // print("t1:",w, idx);
        // print("t2:",sum1[idx / 2], sum2[idx / 2]);
        if (idx % 2 == 0) {  // 奇数番目に挿入
            chmin(ans, sum1[idx / 2] + sum2[idx / 2] + abs(H[idx] - w));
        } else {  // 偶数番目に挿入
            chmin(ans, sum1[idx / 2] + sum2[idx / 2] + abs(H[idx - 1] - w));
        }
    }
    print(ans);

    return 0;
}
