#include <bits/stdc++.h>
#define ll long long
#define fi first
#define sec second
#define N 1000005
using namespace std;
int n,a[N],b[N];
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>>a[i];
    for(int i=1;i<=n;i++)
        cin>>b[i];
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    int i=1,j=1,t=INT_MAX;
    while(i<=n&&j<=n)
    {
        t=min(t,abs(a[i]-b[j]));
        if(a[i]>b[j])
        {
            j++;
        }
        else
        {
            i++;
        }
    }
    cout<<t;
    return 0;
}
