#include <bits/stdc++.h>
using namespace std;
int a[100004],b[100004],n,ans=1e9+1;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    freopen("RBPOINT.INP","r",stdin);
    freopen("RBPOINT.OUT","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
        cin>>b[i];
    sort(b+1,b+n+1);
    for(int i=1;i<=n;i++)
    {
        int p=lower_bound(b+1,b+n+1,a[i])-b;
        if(p!=n+1)
            ans=min(ans,b[p]-a[i]);
        if(p!=1)
            ans=min(ans,a[i]-b[p-1]);
    }
    cout<<ans;
    return 0;
}
