#include<iostream>
#include<vector>
#include<algorithm>
#include<limits>
using namespace std;

int N, M;
vector<int> n, m;

vector<vector<vector<int> > > mem(3001, vector<vector<int> >(101, vector<int>(101, -1)));

int dp (int at, int left, int right) {
  if (at >= N || left - right > 1) return 0;
  if (right < 0) {
    ++left;
    ++right;
  }
  if (mem[at][left][right] != -1) return mem[at][left][right];
  int res = 0;
  //char update = 'N';
  //int prev = 0;
  if (left - right < 0) {
    res = max(res, dp(at, left + 1, right - 1) + m[right]);
    //if (res > prev) {prev = res; update = 'A';};
  }
  if (left - right < 1) {
    res = max(res, dp(at + 1, left, right - 1) + m[right]);
    //if (res > prev) {prev = res; update = 'B';};
    res = max(res, dp(at + 1, left + 1, right) + n[at]);
    //if (res > prev) {prev = res; update = 'D';};
  }
  res = max(res, dp(at + 2, left, right) + n[at]);
  //if (res > prev) {prev = res; update = 'C';};
  res = max(res, dp(at + 1, left, right));
  //if (res > prev) {prev = res; update = 'E';};
  //if (at == N - 2) {
  // res = max(res, dp(at + 2, left, right) + n[at]);
    //if (res > prev) {prev = res; update = 'F';};
  //} else if (at == N - 1) {
  //   res = max(res, dp(at + 1, left, right) + n[at]);
    //if (res > prev) {prev = res; update = 'G';};
  // }
  mem[at][left][right] = res;
  //cout << at << " " << left << " " << right << " = " << res << " " << update << endl;
  return res;
}

int main () {
  cin >> N;
  n.resize(N + 1);
  for (int i = 0; i < N; ++i)
    cin >> n[i];
  cin >> M;
  m.resize(M);
  for (int i = 0; i < M; ++i)
    cin >> m[i];
  sort(m.begin(), m.end());
  n[N] = 0;
  cout << dp(0, 0, M - 1) << endl;
  
  return 0;
}