#include <bits/stdc++.h>
using namespace std;
#define TLHAdepzais1tg ios_base::sync_with_stdio(0);cin.tie();cout.tie(0);
#define ll long long
#define N 100007
#define fi first
#define se second
#define pii pair<ll,ll>
#define str string
int n;
ll b[N],r[N];
ll ans=1e18;
int main()
{
    TLHAdepzais1tg;
    if(fopen("rbpoint.inp","r"))
    {
        freopen("rbpoint.inp","r",stdin);
        freopen("rbpoint.out","w",stdout);
    }
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>b[i];
    for(int i=1;i<=n;i++)
        cin>>r[i];
    sort(b+1,b+n+1);
    sort(r+1,r+n+1);
    for(int i=1;i<=n;i++)
    {
        int vt=lower_bound(r+1,r+n+1,b[i])-r;
        ll res1=vt<=n?abs(r[vt]-b[i]):1e18;
        ll res2=vt>1?abs(r[vt-1]-b[i]):1e18;
        ll res=min(res1,res2);
        ans=min(ans,res);
    }
    cout<<ans;
    return 0;
}

