#include #define For(i, a, b) for(long long i = a; i < b; i++) #define rep(i, n) For(i, 0, n) #define rFor(i, a, b) for(long long i = a; i >= b; i--) #define ALL(v) (v).begin(), (v).end() #define rALL(v) (v).rbegin(), (v).rend() using namespace std; using lint = long long; using ld = long double; int INF = 2000000000; lint LINF = 1000000000000000000; int main() { int n; cin >> n; multiset a; rep(i, n) { int x; cin >> x; a.insert(x); } int m; cin >> m; multiset b; rep(i, m) { int x; cin >> x; b.insert(x); } auto f = [](multiset s, multiset t) { int now = 0; vector v = {-1}; while (true) { bool add = false; if (now == 0) { auto it = s.upper_bound(v.back()); if (it != s.end()) { int x = *it; v.emplace_back(x); s.erase(s.find(x)); add = true; now ^= 1; } } else { auto it = t.upper_bound(v.back()); if (it != t.end()) { int x = *it; v.emplace_back(x); t.erase(t.find(x)); add = true; now ^= 1; } } if (!add) { break; } } return (int)v.size() - 1; }; cout << max(f(a, b), f(b, a)) << endl; }