#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, sub1 = 0, sub2 = 0, empty = 0;
  int num[200010];
  cin >> n >> a >> b;
  for (int i = 1; i <= n; i++) {
    cin >> num[i];
    if (num[i] == 1) {
      if (a)
        a--;
      else if (b) {
        b--;
        empty++;
      } else if (empty)
        empty--;
      else
        sub1++;
    } else {
      if (b)
        b--;
      else
        sub2++;
    }
  }
  cout << sub1 + 2 * sub2 << endl;
  return 0;
}
