#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define endl "\n"
#define f first
#define s second
#define ar array
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define sz(X) ((int)(X).size())
#define pcnt __builtin_popcount
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define get_pos(c, x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define all(X) (X).begin(), (X).end()
#define rall(X) (X).rbegin(), (X).rend()
#define ms(c, x)  memset(c,x,sizeof c)
#define  No(x) cout<<(x?"NO":"No")<<endl;
#define  Yes(x) cout<<(x?"YES":"Yes")<<endl;
#define  nl cout<<endl;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = l; i <=r; i++)
#define ford(i, n) for (int i = n - 1; i >= 0; --i)
using ld = long double;
using db = double;
using str = string;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<db, db>;

using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;

template<typename T>
using osl = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T>
using osg = tree<T, null_type, greater<T>, rb_tree_tag, tree_order_statistics_node_update>;

// for greater use greater<T>
template<typename T>
ostream &operator+(ostream &out, const vector<T> &vec) {
    for (const auto &x : vec) {
        out << x << " ";
    }
    out << "\n";
    return out;
}

template<typename T>
ostream &operator*(ostream &out, const vector<T> &vec) {
    for (const auto &x : vec) {
        out + x;
    }
    return out;
}

template<typename T>
istream &operator>>(istream &in, vector<T> &vec) {
    for (auto &x : vec) {
        in >> x;
    }
    return in;
}

template<class T>
bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }

template<class T>
bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

#ifdef LOCAL

void debug() { cerr << endl; }

template<class T, class... Args>
void debug(const T &t, const Args &... args) {
    cerr << t << " ";
    debug(args...);
}

#define dbg(...) {cerr<<__LINE__<<" [[DEBUG]] ";debug(__VA_ARGS__);};
#else
#define dbg(...) void(0)
#endif
const ll mod = 1e9 + 7;
//const int mod = 998244353;
const ll INF = 1e17 + 6;

inline ll power(ll x, ll y) {
    ll res = 1;
    x = x;
    while (y > 0) {
        if (y & 1)
            res = (res * x);
        y = y >> 1;
        x = (x * x);
    }
    return res;
}

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
const int MXN=3e6+5;

void solve() {
   int n,m;
   cin>>n>>m;
   vl h(n);
   cin>>h;
   vl w(m);
   cin>>w;
   vi pref((n+1)/2+2);
   vi suff((n+1)/2+2);
   sort(all(h));
   for(int i=0;i<n-1;i+=2) {
       pref[i / 2+1] += pref[i / 2] + h[i + 1] - h[i];
   }
   for(int i=n-2;i>0;i-=2) {
       suff[i / 2] += suff[i / 2+1] + h[i+1] - h[i];
   }
   ll ans=INF;
   for(auto i:w){
       int pos=get_pos(h,i);
       if(pos&1){
           pos--;
       }
       ans=min(pref[pos/2]+suff[pos/2]+abs(i-h[pos]),ans);
   }
   cout<<ans<<endl;
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1, tc = 1;
//    cin >> t;
    while (t--) {
        // cout<<"Case #"<<tc<<": " ;
        solve();
        tc++;
    }
#ifdef LOCAL
    cerr << endl << "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
#endif
    return 0;
}
//look if it requires ll
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N,M;
	cin >> N >> M;
	vector<long long> H(N),W(M);
	for(auto &i:H)cin >> i;
	for(auto &i:W)cin >> i;
	
	sort(H.begin(),H.end());
	sort(W.begin(),W.end());
	
	if(N==1){
		long long ans=99999999999999LL;
		for(auto w:W){
			ans=min(ans,abs(w-H[0]));
		}
		cout << ans << endl;
		return 0;
	}
	
	vector<long long> Lsum(N),Rsum(N);
	Lsum[0]=Lsum[1]=H[1]-H[0];
	Rsum[N-1]=Rsum[N-2]=H[N-1]-H[N-2];
	
	for(int i=2;i+1<N;i+=2)Lsum[i]=Lsum[i+1]=Lsum[i-1]+H[i+1]-H[i];
	for(int i=N-3;i-1>=0;i-=2)Rsum[i]=Rsum[i-1]=Rsum[i+1]+H[i]-H[i-1];
	
	int pos=0;
	long long ans=999999999999999999LL;
	for(int i=0;i<M;i++){
		while(pos<N && W[i]>H[pos])pos++;
		long long tmp=0;
		if(pos-2>=0)tmp+=Lsum[pos-2];
		if(pos+1<=N-1)tmp+=Rsum[pos+1];
		if(pos%2)tmp+=W[i]-H[pos-1];
		else tmp+=H[pos]-W[i];
		ans=min(ans,tmp);
	}
	cout << ans << endl;
	return 0;
}