/*
 *  Written by: Richw818
 *  Lang: C++17
 *  main.cpp
 */
#include<bits/stdc++.h>
using namespace std;
//Macros
#define ll long long
#define ld long double
#define ull unsigned long long
#define uint unsigned int
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define str string
#define fi first
#define se second
#define REP(i, n) for(int i = 0; i < (int)n; ++i)
#define sz(a) (int)(a.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
//IO
template<class H, class T> void read(pair<H, T> &p);
template<class T> void read(vector<T>& v);
template<class T> void read(T& t){
    cin >> t;
}
template<class H, class... T> void read(H& h, T&... t){
    read(h);
    read(t...);
}
template<class T> void read(vector<T>& v){
    for(auto &t : v)
        read(t);
}
template<class H, class T> void read(pair<H, T> &p){
    read(p.fi, p.se);
}
void setIn(str s){
    freopen(s.c_str(), "r", stdin);
}
void setOut(str s){
    freopen(s.c_str(), "w", stdout);
}
void setIO(str s = ""){
    cin.tie(0)->sync_with_stdio(0);
    if(sz(s))
        setIn(s+".in"), setOut(s+".out");
}
//Debug
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
template<class H, class... T> void dbg(H& h, T&... t){
    dbg(h);
    dbg(t...);
}
#ifdef LOCAL
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x);
#else
#define dbg(x...)
#endif
//Constants
ll MODS[2] = {1000000007, 998244353};
const ll MOD = MODS[0];
const int INF = (int)1e9;
const ll LINF = (ll)1e18;
const ld PI = acos((ld)-1.0);
const int MAXN = (int)3e5+7;
//Code
void solve(){
    int n, m; read(n, m);
    vector<ll> h(n), w(m); read(h, w);
    sort(all(h));
    vector<ll> pref(n+1);
    for(int i = 1; i <= n; ++i)
        pref[i] = pref[i-1] + (i % 2 ? -h[i-1] : h[i-1]);
    ll ans = LINF;
    for(ll val : w){
        int ind = lower_bound(all(h), val) - h.begin();
        ll curr = 2 * pref[ind] - pref[n];
        curr += (ind % 2 ? val : -val);
        ans = min(ans, curr);
    }
    cout << ans;
}
int main(){
    setIO();
    int t = 1;
    //read(t);
    while(t--) solve();
    return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?)
    * do smth instead of nothing and stay organized
    * WRITE STUFF DOWN
    * DON'T GET STUCK ON ONE APPROACH
*/
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
#include <cstdint>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using P = pair<int,int>;
const int INF=1001001001;
const int mod =998244353;
int main() {
  int N,M;
  cin>>N>>M;
  vector<ll>H(N),W(M);
  for(int i=0;i<N;i++){cin>>H[i];}
  for(int i=0;i<M;i++){cin>>W[i];}
  sort(H.begin(),H.end());
  vector<ll>l(N/2+1),r(N/2+1);
  for(int i=0;i<N/2;i++){
    l[i+1]=l[i]+H[2*i+1]-H[2*i];
    r[i+1]=r[i]+H[2*i+2]-H[2*i+1];//1インデックス
  }
  ll ans=INF;
  for(int i=0;i<M;i++){
    int x=lower_bound(H.begin(),H.end(),W[i])-H.begin();
    if((x&1)==1){x^=1;}//0インデックスならWは偶数番目としか組めない。
    chmin(ans,abs(H[x]-W[i])+l[x/2]+r[N/2]-r[x/2]);
  }
  cout<<ans<<endl;
  return 0;
}