#include <bits/stdc++.h>
using namespace std;
int n,minn=INT_MAX;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie();cout.tie(0);
    if(fopen("RBPOINT.INP","r"))
    {
        freopen("RBPOINT.INP","r",stdin);
        freopen("RBPOINT.OUT","w",stdout);
    }
    cin >> n;
    vector<int> b(n), r(n);
    for(int i = 0; i < n; i++)
        cin >> b[i];
    for(int i = 0; i < n; i++)
        cin >> r[i];
    sort(b.begin(), b.end());
    sort(r.begin(), r.end());
    int i = 0, j = 0;
    while(i < n && j < n)
    {
        int distance = abs(b[i] - r[j]);
        minn = min(minn, distance);
        if (b[i] < r[j])
        i++;
        else j++;
    }
    cout << minn << endl;
}
