#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a)  (a).begin(),(a).end()



int main() {

ll N,M;
cin >> N >> M;

vector<ll> aa((1+N)/2);
vector<ll> bb((1+N)/2);

vector<ll> hh(N);
vector<ll> ww(M);

for(ll i=0;i<N;i++) cin >> hh[i];

for(ll i=0;i<M;i++) cin >> ww[i];

sort(ALL(hh));
ll ans=INF;

aa[0]=0;
for(ll i=1;i<(N+1)/2;i++){
aa[i]=aa[i-1]+hh[2*i-1]-hh[2*i-2];
}

for(ll i=(N-2)/2;i>=0;i--){
bb[i]=bb[i+1]+hh[2*i+2]-hh[2*i+1];
}

for(auto gg : ww){
ll x=lower_bound(ALL(hh),gg)-hh.begin();
 if(x & 1) x^=1;
 chmin(ans,aa[x/2]+bb[x/2]+abs(gg-hh[x]));


}

cout << ans << endl;








}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pdd;

#define lc u << 1
#define rc u << 1 | 1
#define mid (t[u].l + t[u].r) / 2
#define INF 0x3f3f3f3f
#define lowbit(x) x & (-x)
#define mem(a, b) memset(a , b , sizeof(a))
#define FOR(i, x, n) for(int i = x;i <= n; i++)

// const ll mod = 998244353;
// const ll mod = 1e9 + 7;
// const double eps = 1e-6;
// const double PI = acos(-1);
// const double R = 0.57721566490153286060651209;



void solve() {
    int n, m;
    cin >> n >> m;
    vector<ll> v1(n + 1), v2(m + 1);
    for(int i = 1;i <= n; i++) cin >> v1[i];
    for(int i = 1;i <= m; i++) cin >> v2[i];
    sort(v1.begin() + 1, v1.end());
    vector<ll> pre(n + 2), suf(n + 2);
    for(int i = 2;i <= n; i += 2) pre[i] = pre[i - 2] + abs(v1[i] - v1[i - 1]);
    for(int i = n - 1;i >= 1; i -= 2) suf[i] = suf[i + 2] + abs(v1[i + 1] - v1[i]);
    ll ans = 1e18;
    for(int i = 1;i <= m; i++) {
        int pos = lower_bound(v1.begin(), v1.end(), v2[i]) - v1.begin();
        if(pos % 2 == 0) pos--;
        ans = min(ans, (pre[pos - 1] + suf[pos + 1] + abs(v2[i] - v1[pos])));
    }
    cout << ans << endl;
}

signed main() {
    ios_base::sync_with_stdio(false);
    //cin.tie(nullptr);
    //cout.tie(nullptr);
#ifdef FZT_ACM_LOCAL
//    int size=40<<20;
//    __asm__ ("movq %0,%%rsp\n"::"r"((char*)malloc(size)+size));
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    signed test_index_for_debug = 1;
    char acm_local_for_debug = 0;
    do {
        if (acm_local_for_debug == '$') exit(0);
        if (test_index_for_debug > 20)
            throw runtime_error("Check the stdin!!!");
        auto start_clock_for_debug = clock();
        solve();
        auto end_clock_for_debug = clock();
        cout << "Test " << test_index_for_debug << " successful" << endl;
        cerr << "Test " << test_index_for_debug++ << " Run Time: "
             << double(end_clock_for_debug - start_clock_for_debug) / CLOCKS_PER_SEC << "s" << endl;
        cout << "--------------------------------------------------" << endl;
    } while (cin >> acm_local_for_debug && cin.putback(acm_local_for_debug));
#else
    solve();
#endif
    return 0;
}

