#include <bits/stdtr1c++.h>

using namespace std;

typedef long long ll;

ll memo[3005][105][105], n, m, a[3005], b[105];
ll dp(int i, int j, int k) {
	if (memo[i][j][k] != 0) return memo[i][j][k];
	
	ll& val = memo[i][j][k] = 0;
	if (i < n) {
		if (i + 1 <= n) val = max(val, a[i] + dp(i+2, j, k));
		val = max(val, dp(i+1, j, k));
	}
	
	if (j < k) {
		if (j < k-1) val = max(val, b[k-1] + dp(i, j+1, k-1));
		val = max(val, dp(i, j+1, k));
	}
	
	if (i < n && j < k) {
		val = max(val, a[i] + dp(i+1, j+1, k));
		val = max(val, b[k-1] + dp(i+1, j, k-1));
	}
	return val;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	sort(b, b+m);
	
	cout << dp(0, 0, m) << endl;
	return 0;
}