#include <bits/stdc++.h>
#define ll long long
#define name "RBPOINT"
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);if(fopen(name".INP","r")){freopen(name".INP","r",stdin);freopen(name".OUT","w",stdout);}
using namespace std;
ll n,b[100001],r[100001];
int main(){
    fast
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>b[i];
    for(int i=0;i<n;i++)
        cin>>r[i];
    sort(b,b+n);
    sort(r,r+n);
    ll i=0,j=0,mi=LLONG_MAX;
    while(i<n&&j<n){
        mi=min(mi,abs(b[i]-r[j]));
        if(b[i]<r[j])i++;
        else j++;
    }
    cout<<mi;
    return 0;
}
