#include <bits/stdc++.h>
#define ll long long
#define N 100003
#define ok "RBPOINT"
#define fi first
#define se second
#define pb push_back
#define pii pair <int,int>
#define mp make_pair
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define name if (fopen(ok".INP","r")){ freopen(ok".INP","r",stdin); freopen(ok".OUT","w",stdout);}
using namespace std;
int n,a[N],b[N],min1=1e9;
int main()
{
    fast name
    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);
    for (int i=1;i<=n;i++)
    {
        int k=lower_bound(b+1,b+n+1,a[i])-b;
        if (k!=n+1) min1=min(min1,b[k]-a[i]);
    }
    for (int i=1;i<=n;i++)
    {
        int k=lower_bound(a+1,a+n+1,b[i])-a;
        if (k!=n+1) min1=min(min1,a[k]-b[i]);
    }
    cout<<min1;
    return 0;
}
