#include <bits/stdc++.h>
using namespace std;
int n, t1, t2, t3, s, t;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> t1 >> t2;
  for (int i = 0; i < n; i++) {
    int p;
    cin >> p;
    t += p;
    if (p == 2) {
      if (t2 > 0) {
        t2--;
        s += 2;
      } else {
        continue;
      }
    } else {
      if (t1 > 0) {
        t1--;
        s += 1;
      } else if (t2 > 0) {
        t2--;
        t3++;
        s += 1;
      } else if (t3 > 0) {
        t3--;
        s += 1;
      } else {
        continue;
      }
    }
  }
  cout << t - s;
  return 0;
}
