#include <bits/stdc++.h>
int main() {
  long long n, a, r = 0, b;
  float m = 0;
  scanf("%lld %lld %lld", &n, &a, &b);
  int t[n];
  for (long long i = 0; i < n; i++) {
    scanf("%d", &t[i]);
  }
  for (long long i = 0; i < n; i++) {
    if (t[i] == 2) {
      if (b >= 1) {
        b = b - 1;
      } else {
        r = r + 2;
      }
    } else if (t[i] == 1) {
      if (a >= 1) {
        a = a - 1;
      } else {
        if (b >= 1) {
          b = b - 1;
          m = m + 0.5;
        } else if (m > 0 && b >= 0) {
          m = m - 0.5;
        } else {
          r = r + 1;
        }
      }
    }
  }
  printf("%lld", r);
  return 0;
}
