1.
#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>
using namespace std;
int dfs(vector<int>& h, int j0, int j1, int j2, int cur) {
int res = INT_MAX;
int n = h.size();
int left = n - cur;
if (left == 0) return 0;
if (left >= 1 && j0 > 0) res = min(res, dfs(h, j0 - 1, j1, j2, cur + 1) + h[cur + 1 - 1]);
if (left >= 2 && j1 > 0) res = min(res, dfs(h, j0, j1 - 1, j2, cur + 2) + h[cur + 2 - 1]);
if (left >= 3 && j2 > 0) res = min(res, dfs(h, j0, j1, j2 - 1, cur + 3) + h[cur + 3 - 1]);
return res;
}
int main() {
int n;
cin >> n;
if (n == 0) cout << "0";
vector<int> h(n);
for (int i = 0; i < n; i++) {
cin >> h[i];
}
int j[3];
for (int i = 0; i < 3; i++)
cin >> j[i];
int res = dfs(h, j[0], j[1], j[2], 0);
cout << res;
return 0;
}