#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,max1=INT_MAX;
pair<ll,ll> p[1000005];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    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 >> p[i].first;
        p[i].second = -1;
    }
    for(int i=1;i<=n;i++)
    {
        cin >> p[i+n].first;
        p[i+n].second = 1;
    }
    n*=2;
    sort(p+1,p+n+1);
    for(int i=1;i<n;i++)
    {
        if(p[i].second!=p[i+1].second)
        {
            max1 = min(max1,p[i+1].first-p[i].first);
        }
    }
    cout << max1;
}
