#include<bits/stdc++.h>
using namespace std;
int n,m,h[200003],w[200003];
long long sum[2][200003],ans=2333333333333333;
int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++)
		scanf("%d",h+i);
	for(int i=0;i<m;i++)
		scanf("%d",w+i);
	sort(w,w+m);
	sort(h,h+n);
	for(int i=0;i+1<n;i+=2)
		sum[0][i+2]=sum[0][i]+h[i+1]-h[i];
	for(int i=n-1;i>0;i-=2)
		sum[1][n+1-i]=sum[1][n-1-i]+h[i]-h[i-1];
	for(int i=0,j=0;i<m;i++){
		while(j!=n&&w[i]>h[j])j++;
		int l=int(j/2)*2,r=n-1-l;
		int LST=j;if(j%2)LST--;
		ans=min(ans,sum[0][2*int(l/2)]+sum[1][2*int(r/2)]+int(fabs(w[i]-h[LST])));
	}
	cout<<ans;
}
#include<bits/stdc++.h>
#define LL long long
#define ull unsigned long long
#define F(i,j,k) for(int i=(j);i<=(k);i++)
#define DF(i,j,k) for(int i=(j);i>=(k);i--)
#define P pair
#define dui priority_queue
using namespace std;
template<typename T>inline void read(T &n){
    T w=1;n=0;char ch=getchar();
    while(!isdigit(ch)&&ch!=EOF){if(ch=='-')w=-1;ch=getchar();}
    while(isdigit(ch)&&ch!=EOF){n=(n<<1)+(n<<3)+(ch^48);ch=getchar();}
    n*=w;
}
template<typename T>inline void write(T x){
    ull y=0;
    T l=0;
    if(x<0){x=-x;putchar('-');}
    if(!x){putchar(48);return;}
    while(x){y=y*10+x%10;x/=10;l++;}
    while(l){putchar(y%10+48);y/=10;l--;}
}
template<typename T>inline void writeln(T x){
    write(x);
    puts("");
}
template<typename T>inline void writes(T x){
    write(x);
    putchar(' ');
}
template<typename T>inline void checkmax(T &a,T b){a=a>b?a:b;}
template<typename T>inline void checkmin(T &a,T b){a=a<b?a:b;}
const int N=1e5+100;
LL ans,a[N],b[N],c[N];
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;read(n);
	F(i,1,n)read(a[i]);F(i,1,n)read(b[i]);
	F(i,1,n)if(i&1)ans+=a[i],c[i]=b[i]-a[i];else ans+=b[i],c[i]=a[i]-b[i];
	sort(c+1,c+n+1);
	F(i,n/2+1,n)ans+=c[i];
	writeln(ans);
    return 0;
}

