#define _USE_MATH_DEFINES #include using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector a(n + 1), b(n + 1); for (auto& x : a) cin >> x; for (auto& x : b) cin >> x; vector> val(n + 1, vector(n + 1)); for (int i = 0; i < n + 1; i++) for (int j = 0; j < n + 1; j++) val[i][j] = a[i] + b[j]; vector d(n); for (auto& x : d) cin >> x; sort(d.begin(), d.end()); vector> dp(n + 1, vector(n + 1, -(1 << 30))); dp[0][0] = n; for (int i = 0; i < n + 1; i++) for (int j = 0; j < n + 1; j++) { if (i == 0 && j == 0) continue; int idx = upper_bound(d.begin(), d.end(), val[i][j]) - d.begin(); idx--; if (i > 0) dp[i][j] = max(dp[i][j], min(idx, dp[i - 1][j] - 1)); if (j > 0) dp[i][j] = max(dp[i][j], min(idx, dp[i][j - 1] - 1)); } vector> cnt(n + 1, vector(n + 1)); cnt[0][0] = 0; for (int i = 0; i < n + 1; i++) for (int j = 0; j < n + 1; j++) { if (i > 0 && dp[i][j] >= 0 && dp[i][j] < dp[i - 1][j]) cnt[i][j] = max(cnt[i][j], cnt[i - 1][j] + 1); if (j > 0 && dp[i][j] >= 0 && dp[i][j] < dp[i][j - 1]) cnt[i][j] = max(cnt[i][j], cnt[i][j - 1] + 1); } int ans = 0; for (int i = 0; i < n + 1; i++) for (int j = 0; j < n + 1; j++) ans = max(ans, cnt[i][j]); cout << ans << endl; return 0; }