#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;
const int MOD = 1000000007;
const double pi = acos(-1);
ll gcd(ll a, ll b) {if(b == 0) return a; else return gcd(b,a%b);}
ll lcm(ll a, ll b) {return a*b/gcd(a,b);}

ll INF = 1LL<<60;

int main() {
    int N; cin >> N;
    int M; cin >> M;
    vecl H(N), W(M);
    REP(i,N) cin >> H[i];
    REP(i,M) cin >> W[i];

    sort(H.begin(),H.end());

    vecl L(200010), R(200010);
    for(int i = 2; i < N; i++) {
        L[i] = L[i-2] + H[i-1] - H[i-2];
        R[i] = R[i-2] + H[N-i+1] - H[N-i];
    }

    ll ans = INF;

    for(ll w : W) {
        int i = lower_bound(H.begin(),H.end(),w) - H.begin();
        if(i%2 == 0) chmin(ans,L[i]+R[N-i-1] + H[i]-w);
        else chmin(ans,L[i-1] + R[N-i] + w-H[i-1]);
    }

    cout << ans << endl;
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF32 2147483647 //2.147483647×10^{9}:32bit整数のinf



int main(){
    int H,W;
    cin >> H >> W;
    vector<int > A(H*W);
    int amin=10000;
    for(int i=0; i<H*W; i++){
        cin >> A.at(i);
        amin = min(amin,A.at(i));
    }
    int ans=0;
    for(int i=0; i<H*W; i++){
        ans += A.at(i) - amin;
    }

    cout << ans << endl;
}
