#include [[nodiscard]] static inline uint_fast32_t prepare([[maybe_unused]] const uint_fast32_t N, const uint_fast32_t M, const std::vector& S, const std::vector& T) noexcept { [[assume(std::is_sorted(S.begin(), S.end()))]]; std::multiset unused_S; for (const auto& s : S) unused_S.insert(s); uint_fast32_t x; for (x = 0; x != M; ++x) { const auto itr = unused_S.lower_bound(T[x]); if (itr == unused_S.end()) break; unused_S.erase(itr); } return x; } [[nodiscard]] static inline uint_fast32_t solve(const uint_fast32_t N, const uint_fast32_t M, const std::vector& S, std::vector& T) noexcept { [[assume(std::is_sorted(S.begin(), S.end()))]]; const uint_fast32_t x = prepare(N, M, S, T); std::sort(T.begin(), T.begin() + x); uint_fast32_t ans = 0; for (uint_fast32_t i = 0, j = 0; j != x; ++i, ++j) { while (S[i] < T[j]) ++i; ans = std::max(ans, S[i] - T[j]); } return ans; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); uint_fast32_t N, M; std::cin >> N >> M; std::vector S(N), T(M); for (auto& s : S) std::cin >> s; for (auto& t : T) std::cin >> t; std::sort(S.begin(), S.end()); std::cout << solve(N, M, S, T) << '\n'; return 0; }