/**
    HOANG HAI DANG
    --------------
    THCS NGUYEN DU
*/
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define name if(fopen("RBPOINT.INP","r")) { freopen("RBPOINT.INP","r",stdin); freopen("RBPOINT.OUT","w",stdout); }
using namespace std;
ll a[1000005],b[1000005];
int32_t main()
{
    #ifndef RBPOINT
    name;
    #endif // RBPOINT
    fast;
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=n;i++)
    {
        cin>>b[i];
    }
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    ll i=1,j=1;
    ll nn=LLONG_MAX;
    while(i<=n&&j<=n)
    {
        nn=min(nn,abs(a[i]-b[j]));
        if(a[i]<b[j])
        {
            i++;
        }
        else
        {
            j++;
        }
    }
    cout<<nn<<"\n";
    return 0;
}
