#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;

int main(){
  int n,m;
  cin >> n >> m;
  vl h(n),w(m),a(n),s(n);
  rep(i,n)cin >> h[i];
  rep(i,m)cin >> w[i];
  sort(h.begin(),h.end());
  sort(w.begin(),w.end());
  for(int i=0;i<n-1;i++){
    a[i]=h[i+1]-h[i];
    if(i==0 or i==1) s[i]=a[i];
    else s[i]=s[i-2]+a[i];
  }
  ll ans=1e14;
  if(n==1){
    rep(i,m) ans=min(ans,abs(h[0]-w[i]));
  }else rep(i,m){
    //cout << ans << "\n";
    int insert=lower_bound(h.begin(),h.end(),w[i])-h.begin();
    int counter;
    if(insert%2==0){
      if(insert==0) ans=min(ans,(h[0]-w[i])+s[n-2]);
      else if(insert==n-1) ans=min(ans,s[n-3]+(h[n-1]-w[i]));
      else ans=min(ans,s[insert-2]+(h[insert]-w[i])+(s[n-2]-s[insert-1]));
    }else{
      if(insert==n) ans=min(ans,(w[i]-h[n-1])+s[n-3]);
      else if(insert==1) ans=min(ans,(w[i]-h[0])+s[n-2]);
      else ans=min(ans,s[insert-3]+(w[i]-h[insert-1])+(s[n-2]-s[insert-2]));
    }
  }
  cout << ans;
  return 0;
}
 //
#include<bits/stdc++.h>

using namespace std;

#define PB push_back
#define f fiCrst
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int INF = 1000000007;
const ll MOD = 1000000007;

void solve_test()
{
    int n, m;
    cin >> n >> m;
    ll h[n+1];
    h[0] = -INF;
    ll tot = 0;
    for(int i=1; i<=n; i++)
    {
        cin >> h[i];
        tot += h[i];
    }
    sort(h+1, h+n+1);
    ll sum[n+1][2];
    memset(sum, 0, sizeof(sum));
    sum[1][1] = h[1];
    for(int i=2; i<=n; i++)
    {
        for(int j=0; j<2; j++)
        {
            sum[i][j] = sum[i-1][j];
        }
        sum[i][i%2] += h[i];
    }
    ll ans = 1e18;
    for(int i=0; i<m; i++)
    {
        ll x;
        cin >> x;
        int ind = upper_bound(h, h+n+1, x) - h;
        ll sum1 = sum[ind-1][ind%2];
        sum1 += sum[n][(ind+1)%2] - sum[ind-1][(ind+1)%2];
        ll sum2 = tot - sum1;
        sum1 += x;
//        what_is(x);
//        what_is(sum1);
//        what_is(sum2);
        ans = min(ans, abs(sum1-sum2));
    }
    cout << ans;
}

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int tests;
    tests = 1;
    //cin >> tests;
    while(tests--)
    {
        solve_test();
    }
    return 0;
}
