#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
const int INF = 1001001001;
void chmin(int &a, int b) { if (a > b) a = b; }
int main() {
int N, M; cin >> N >> M;
vector<int> A(N), B(M);
rep(i, N) cin >> A[i];
rep(i, M) cin >> B[i];
sort(all(A));
sort(all(B));
int j = 0, ans = INF;
rep(i, N) {
// 末端まで行くか「B[j] >= A[i]」を満たすようになるまでjを増やしていく
while (j + 1 < M && B[j] < A[i]) j++;
chmin(ans, abs(A[i] - B[j]));
if (j - 1 >= 0) chmin(ans, abs(A[i] - B[j - 1]));
}
cout << ans << endl;
}