#include <bits/stdc++.h>
using namespace std;
bool compare2(const pair<long, long> &i, const pair<long, long> &j) {
  return i.second > j.second;
}
bool compare1(const pair<long, long> &i, const pair<long, long> &j) {
  return i.first > j.first;
}
bool compare3(const pair<long, long> &i, const pair<long, long> &j) {
  return i.first < j.first;
}
bool compare(const long &i, const long &j) { return i > j; }
struct setComp {
  bool operator()(const pair<long, long> &a, const pair<long, long> &b) const {
    return a.second >= b.second;
  }
};
int main() {
  long n, a, b;
  cin >> n >> a >> b;
  int t;
  long p = 0;
  long count = 0;
  for (long i = 0; i < n; i++) {
    cin >> t;
    if (t == 2) {
      if (b == 0)
        count += 2;
      else
        b--;
    } else {
      if (a == 0 && p == 0 && b == 0)
        count++;
      else if (a != 0) {
        a--;
      } else if (a == 0 && b != 0) {
        b--;
        p++;
      } else if (a == 0 && b == 0 && p != 0) {
        p--;
      }
    }
  }
  cout << count << endl;
  return 0;
}
