#include<bits/stdc++.h>
#define ll long long
#define ii pair<ll,ll>
#define x first
#define y second
using namespace std;
const long o=200005;
ll n,it[2][4*o];
ii a[o];
vector<ii>p[2];
void build(long db,long x,long l,long r)
{
    if(l==r)
    {
        it[db][x]=p[db][l].y;
        return;
    }
    long mid=(l+r)>>1;
    build(db,2*x,l,mid);
    build(db,2*x+1,mid+1,r);
    it[db][x]=min(it[db][2*x],it[db][2*x+1]);
}
ll get(long db,long x,long l,long r,long u,long v)
{
    if(u>v || v<l || u>r)
        return 1e9;
    if(u<=l && r<=v)
        return it[db][x];
    long mid=(l+r)>>1;
    return min(get(db,2*x,l,mid,u,v),get(db,2*x+1,mid+1,r,u,v));
}
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

	cin>>n;
	for(long i=1;i<=n;i++)
        cin>>a[i].x;

    ll kq=0;
    for(long i=1;i<=n;i++)
    {
        cin>>a[i].y;
        if(a[i].x<a[i].y)p[0].push_back({a[i].y,a[i].x});
        if(a[i].x>a[i].y)p[1].push_back(a[i]);
        kq+=abs(a[i].x-a[i].y);
    }


    sort(p[0].begin(),p[0].end());
    sort(p[1].begin(),p[1].end());
    if(p[0].size()==0 || p[1].size()==0)
    {
        cout<<kq;
        return 0;
    }

    build(0,1,0,p[0].size()-1);
    build(1,1,0,p[1].size()-1);
    ll l=0,r=1e9;
    while(l<r)
    {
        ll mid=(l+r+1)>>1;
        bool ok=0;
        for(long i=0;i<p[0].size();i++)
        if(p[0][i].x-p[0][i].y>=mid)
        {
            long vt=lower_bound(p[1].begin(),p[1].end(),ii(p[0][i].y+mid,0))-p[1].begin();
            if(get(1,1,0,p[1].size()-1,vt,p[1].size()-1)<=p[0][i].y)
            {
                ok=1;
                break;
            }
        }
        for(long i=0;i<p[1].size();i++)
        if(p[1][i].x-p[1][i].y>=mid)
        {
            long vt=lower_bound(p[0].begin(),p[0].end(),ii(p[1][i].y+mid,0))-p[0].begin();
            if(get(0,1,0,p[0].size()-1,vt,p[0].size()-1)<=p[1][i].y)
            {
                ok=1;
                break;
            }
        }
        if(ok)l=mid;
        else r=mid-1;
    }
    cout<<kq-l*2;
    return 0;
}
