#include <bits/stdc++.h>
inline void in(int &MAGNUS) { scanf("%d", &MAGNUS); }
inline void out(int MAGNUS) { printf("%d\n", MAGNUS); }
inline void in(int &MAGNUS, int &CLAR) { scanf("%d%d", &MAGNUS, &CLAR); }
inline void out(int MAGNUS, int CLAR) { printf("%d %d\n", MAGNUS, CLAR); }
inline void inl(long long &LIV) { scanf("%lld", &LIV); }
inline void inl(long long &LIV, long long &MART) {
  scanf("%lld%lld", &LIV, &MART);
}
inline void outl(long long LIV) { printf("%lld\n", LIV); }
inline void outl(long long LIV, long long MART) {
  printf("%lld %lld\n", LIV, MART);
}
using namespace std;
int main() {
  int N, one, two, twoone = 0;
  in(N);
  in(one, two);
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    int x;
    in(x);
    if (x == 1) {
      if (one > 0)
        one--;
      else {
        if (two > 0)
          two--, twoone++;
        else if (twoone > 0)
          twoone--;
        else
          ans++;
      }
    } else if (x == 2) {
      if (two == 0)
        ans += 2;
      else
        two--;
    }
  }
  out(ans);
  return 0;
}
