#include<bits/stdc++.h>
using namespace std;
int a[100005],b[100005];
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);
    }
    int n , mi = INT_MAX; 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 ;
    while(i<= n && j <= n)
    {
        mi = min (mi , abs(a[i]-b[j]));
        if (a[i]>b[j])
            j++;
        else
            i++;
    }
    cout << mi;
    return 0;
}
