#include <bits/stdc++.h>
#define task "RBPOINT"
#define Yin ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define xD if (fopen(task".INP", "r")){freopen(task".INP", "r", stdin);freopen(task".OUT", "w", stdout);}
#define f  first
#define s second

using namespace std;

int n;
long long a[1000006], b[1000006];
long long res = 1e10;
int main()
{
    Yin xD
    cin >> n;
    for(int i = 1;i <= n;i += 1)
        cin >> a[i];
    for(int i = 1;i <= n;i += 1)
        cin >> b[i];
    sort(b+1,b+n+1);
    b[0] = INT_MIN;
    for(int i = 1;i <= n;i += 1)
    {
        int x = lower_bound(b,b+n+1,a[i]) - b;
        res = min({res,abs(a[i] - b[x]),abs(a[i] - b[x-1])});
    }
    cout << res;
    return 0;
}
