#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, M; cin >> N >> M; vector S(N), T(M); for (int i = 0; i < N; i++) cin >> S[i]; for (int i = 0; i < M; i++) cin >> T[i]; if (T[0] > *max_element(S.begin(), S.end())) { cout << 0 << "\n"; return 0; } multiset L(S.begin(), S.end()); vector TT; for (auto i : T) { auto it = L.lower_bound(i); if (it == L.end()) break; L.erase(it); TT.push_back(i); } sort(TT.begin(), TT.end()); L = multiset(S.begin(), S.end()); long long ans = 0; for (auto i : TT) { auto it = L.lower_bound(i); long long a = *it; L.erase(it); ans = max(ans, a - i); } cout << ans << "\n"; return 0; }