#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, aa = 0, bb = 0, ba = 0, sum = 0;
  cin >> n >> a >> b;
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    if (x == 1) {
      if (aa + 1 <= a) {
        aa = aa + 1;
      } else if (bb + 1 <= b) {
        bb = bb + 1;
        ba = ba + 1;
      } else if (bb == b && ba != 0) {
        ba = ba - 1;
      } else
        sum++;
    } else {
      if (bb + 1 <= b) {
        bb = bb + 1;
      } else
        sum = sum + 2;
    }
  }
  cout << sum << endl;
  return 0;
}
