#include <bits/stdc++.h>
using namespace std;
const long long int MAXN = 9223372036854775806;
const long long int ARR = 3 * 1000 * 100 + 256;
const int MAXM = 2147483647;
double l(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
int main() {
  int n, a, b, c = 0, ans = 0;
  cin >> n >> a >> b;
  for (int i = 1; i <= n; i++) {
    int h;
    cin >> h;
    if (h == 1) {
      if (a > 0) {
        a--;
        continue;
      } else if (b > 0) {
        b--;
        c++;
        continue;
      } else if (c > 0) {
        c--;
        continue;
      } else {
        ans++;
        continue;
      }
    } else {
      if (b > 0) {
        b--;
        continue;
      } else {
        ans++;
        ans++;
        continue;
      }
    }
  }
  cout << ans;
  return 0;
}
