#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll a[1000005],b[1000005];
ll res = LLONG_MAX;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    freopen("RBPOINT.INP","r",stdin);
    freopen("RBPOINT.OUT","w",stdout);
    ll n;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);
    ll i = 1,j = 1;
    while(i <= n && j <= n){
        ll x = b[j]-a[i];
        if(x == 0){
            cout << 0;
            return 0;
        }
        if(x > 0){
            i++;
        }
        else{
            j++;
        }
        res = min(res,abs(x));
    }
    cout << res;
}
