#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
freopen("RT.in","r",stdin);
freopen("RT.out","w",stdout);
int n,a,b,un=0;
scanf("%d%d%d",&n,&a,&b);
int member,twotoone=0;
for (int i = 0; i < n; ++i)
{
scanf("%d",&member);
if (member==1)
{
if (a)
a--;
else if (b)
{
b--;
twotoone++;
}
else if (twotoone)
twotoone--;
else un++;
}
if (member==2)
{
if (b)
b--;
else
un+=2;
}
}
printf("%d\n",un );
return 0;
}