var data = readline().split(' ').map(function (x) { return parseInt(x); });
var guests = readline().split(' ').map(function (x) { return parseInt(x); });

var sTable = data[1];
var dTable = data[2];
var seat = 0;

var total = guests.reduce(function (a,b) {
  return a + b;
}, 0);

for (var g of guests) {
 if (g === 2) {
   if (dTable !== 0) {
     dTable--;
     total -= g;
   }
 }
 if (g === 1) {
   if (sTable !== 0) {
     sTable--;
     total -= g;
   } else if (dTable !== 0) {
     dTable--;
     seat++;
     total -= g;
   } else if (seat !== 0) {
     seat--;
     total -= g;
   }
 }

}

print(total);

var data = readline().split(' '),
    people = readline().split(' '),
    n = parseInt(data[0]),
    a = parseInt(data[1]),
    b = parseInt(data[2]),
    temp = 0,
    output = 0;

for(var i = 0; i < people.length; i++) {
    if(parseInt(people[i]) === 1) {
        if(a !== 0) {
            a = a - 1;
        } else if(b !== 0) {
            b = b - 1;
            temp = temp + 1;
        } else if(b === 0 && temp !== 0) {
            temp = temp - 1;
        } else {
            output = output + 1;
        }
    } else {
        if(b !== 0) {
            b = b - 1;
        } else {
            output = output + 2;
        }
    }
}

print(output);

/**
 *
In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them,
it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person.
 If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input
The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant,
the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order.
 If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output
Print the total number of people the restaurant denies service to.

Examples
input
4 1 2
1 2 1 1
output
0
input
4 1 1
1 1 2 1
output
2
Note
In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table.
The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person,
 he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person,
it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them.
The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let numberOfGroups = Number(inputString[0].split(" ")[0]);
    let numberOfOneSeater = Number(inputString[0].split(" ")[1]);
    let numberOfTwoSeater = Number(inputString[0].split(" ")[2]);
    let groups = inputString[1].split(" ")

    solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups)

});

function solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups) {

    let sum = 0;
    let numberOfTwoSeaterOccupiedByOnePerson = 0;

    for (let index = 0; index < numberOfGroups; index++) {

        if (groups[index] == 1 && numberOfOneSeater > 0) {

            numberOfOneSeater--;
            groups[index] = 0;
        }

        else if (groups[index] == 1 && !numberOfOneSeater  && numberOfTwoSeater > 0) {

            numberOfTwoSeaterOccupiedByOnePerson++;
            numberOfTwoSeater--;
            groups[index] = 0;
        }

        else if (groups[index] == 1 && !numberOfOneSeater  && !numberOfTwoSeater&& numberOfTwoSeaterOccupiedByOnePerson > 0) {

            numberOfTwoSeaterOccupiedByOnePerson--;
            groups[index] = 0;
        }

        else if (groups[index] > 0 && groups[index] != 1 && numberOfTwoSeater > 0) {

            numberOfTwoSeater--;
            groups[index] = 0;
        }

    }

    for (let index = 0; index < numberOfGroups; index++) {

        sum += parseInt(groups[index]);
    }

    console.log(sum);
}

function GetAns(n, a, b, array){
	var ans=0;
	var tOne, tTwo, tTwoWithOne;
	tOne = a; tTwo = b; tTwoWithOne = 0;
	for (var i=0;i<n;i++){
		if ((+array[i])===2){
			if (tTwo>0)
				tTwo--;
			else
				ans+=2;
		}
		else{
			if (tOne>0)
				tOne--;
			else{
				if (tTwo>0){
						tTwo--;
						tTwoWithOne++;
					}
				else
					if (tTwoWithOne>0) tTwoWithOne--;
					else
							ans++;
			}
		}
	}
	return ans;
}

var input = readline().split(' ');
var n=+input[0], a=+input[1], b=+input[2];
var array=readline().split(' ');
print(GetAns(n,a,b,array));

let _inputLines;
let _lineNumber = 0;
let inputReader = _inputReader ();

function _main() {

	_inputLines = _inputData.trim().split('\n').map((string) => {
		return string.trim();
	});;
	let [n, a, b] = inputReader.readNumberArray();
	let arr = inputReader.readNumberArray();
	let extra = 0;
	let count = 0;
	for (let i = 0; i < arr.length; i++) {
		if (arr[i] === 1) {
			if (a > 0) a--;
			else if (b > 0) {
				b--;

				extra++;
			} else if (extra > 0) {
				extra--;
			} else count++;
		} else {
			if (b > 0) b--;
			else count += 2;
		}
	}
	console.log(count);

}

var _inputData = '';
function cacheInput(data) {
	_inputData += data;
}

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', cacheInput).on('end', _main);

function _inputReader () {
	function readNumberArray(){
		return _inputLines[_lineNumber++].split(' ').map(val => Number(val));
	}

	return {
		readNumberArray,
	}
}

/**
 *
In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them,
it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person.
 If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input
The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant,
the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order.
 If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output
Print the total number of people the restaurant denies service to.

Examples
input
4 1 2
1 2 1 1
output
0
input
4 1 1
1 1 2 1
output
2
Note
In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table.
The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person,
 he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person,
it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them.
The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let numberOfGroups = Number(inputString[0].split(" ")[0]);
    let numberOfOneSeater = Number(inputString[0].split(" ")[1]);
    let numberOfTwoSeater = Number(inputString[0].split(" ")[2]);
    let groups = inputString[1].split(" ")

    solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups)

});

function solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups) {

    let sum = 0;
    for (let index = 0; index < numberOfGroups; index++) {

        if (groups[index] == 1 && numberOfOneSeater > 0) {

            numberOfOneSeater--;
            groups[index] = 0;
        }

        else if (groups[index] == 1 && !numberOfOneSeater && numberOfTwoSeater > 0) {

            numberOfOneSeater++;
            numberOfTwoSeater--;
            groups[index] = 0;
        }

        else if (groups[index] != 1 && numberOfTwoSeater > 0) {

            numberOfTwoSeater--;
            groups[index] = 0;
        }
    }

     sum = groups => groups.reduce((a,b) => a + b, 0)

    console.log(sum);
}

/**
 *
In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them,
it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person.
 If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input
The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant,
the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order.
 If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output
Print the total number of people the restaurant denies service to.

Examples
input
4 1 2
1 2 1 1
output
0
input
4 1 1
1 1 2 1
output
2
Note
In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table.
The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person,
 he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person,
it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them.
The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let numberOfGroups = Number(inputString[0].split(" ")[0]);
    let numberOfOneSeater = Number(inputString[0].split(" ")[1]);
    let numberOfTwoSeater = Number(inputString[0].split(" ")[2]);
    let groups = inputString[1].split(" ")

    solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups)

});

function solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups) {

    let sum = 0;
    for (let index = 0; index < numberOfGroups; index++) {

        if (groups[index] == 1 && numberOfOneSeater > 0) {

            numberOfOneSeater--;
            groups[index] = 0;
        }

        else if (groups[index] == 1 && numberOfOneSeater == 0 && numberOfTwoSeater > 0) {

            numberOfOneSeater += 2;
            numberOfTwoSeater--;
            groups[index] = 0;
        }

        else if (groups[index] != 1 && numberOfTwoSeater > 0) {

            numberOfTwoSeater--;
            groups[index] = 0;
        }
    }

    for (let index = 0; index < numberOfGroups; index++) {

        sum += Number(groups[index]);
    }

    console.log(sum);
}

/**
 *
In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them,
it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person.
 If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input
The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant,
the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order.
 If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output
Print the total number of people the restaurant denies service to.

Examples
input
4 1 2
1 2 1 1
output
0
input
4 1 1
1 1 2 1
output
2
Note
In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table.
The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person,
 he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person,
it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them.
The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let numberOfGroups = Number(inputString[0].split(" ")[0]);
    let numberOfOneSeater = Number(inputString[0].split(" ")[1]);
    let numberOfTwoSeater = Number(inputString[0].split(" ")[2]);
    let groups = inputString[1].split(" ")

    solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups)

});

function solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups) {

    let sum = 0;
    for (let index = 0; index < numberOfGroups; index++) {

        if (groups[index] == 1 && numberOfOneSeater > 0) {

            numberOfOneSeater--;
            groups[index] = 0;
        }

        else if (groups[index] == 1  && numberOfTwoSeater > 0) {

            numberOfOneSeater++;
            numberOfTwoSeater--;
            groups[index] = 0;
        }

        else if (groups[index] != 1 && numberOfTwoSeater > 0) {

            numberOfTwoSeater--;
            groups[index] = 0;
        }
    }

    for (let index = 0; index < numberOfGroups; index++) {

        sum += parseInt(groups[index]);
    }

    console.log(sum);
}

/**
 *
In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them,
it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person.
 If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input
The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant,
the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order.
 If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output
Print the total number of people the restaurant denies service to.

Examples
input
4 1 2
1 2 1 1
output
0
input
4 1 1
1 1 2 1
output
2
Note
In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table.
The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person,
 he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person,
it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them.
The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let numberOfGroups = inputString[0].split(" ")[0];
    let numberOfOneSeater = inputString[0].split(" ")[1];
    let numberOfTwoSeater = inputString[0].split(" ")[2];
    let groups = inputString[1].split(" ")

    solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups)

});

function solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups) {

    let sum = 0 ;
    for (let index = 0; index < numberOfGroups; index++) {

        if (Number(groups[index]) == 1 && numberOfOneSeater > 0) {
            numberOfOneSeater--;
            groups[index] = 0
        }

        else if(Number(groups[index]) == 1 && numberOfOneSeater == 0 && numberOfTwoSeater > 0){

            numberOfOneSeater++;
            numberOfTwoSeater--;
            groups[index] = 0
        }

        else if (Number(groups[index]) != 1 && numberOfTwoSeater > 0) {
            numberOfTwoSeater--;
            groups[index] = 0
        }
    }

    for(let index = 0 ; index < numberOfGroups ; index ++){

        sum += Number(groups[index])
    }

    console.log(sum)
}

/**
 *
In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them,
it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person.
 If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input
The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant,
the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order.
 If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output
Print the total number of people the restaurant denies service to.

Examples
input
4 1 2
1 2 1 1
output
0
input
4 1 1
1 1 2 1
output
2
Note
In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table.
The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person,
 he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person,
it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them.
The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let numberOfGroups = Number(inputString[0].split(" ")[0]);
    let numberOfOneSeater = Number(inputString[0].split(" ")[1]);
    let numberOfTwoSeater = Number(inputString[0].split(" ")[2]);
    let groups = inputString[1].split(" ")

    solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups)

});

function solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups) {

    let sum = 0;
    let totalSum = 0 ;

    for (let index = 0; index < numberOfGroups; index++) {

        if (groups[index] == 1 && numberOfOneSeater > 0) {

            numberOfOneSeater--;
            sum++;
        }

        else if (groups[index] == 1 && !numberOfOneSeater  && numberOfTwoSeater > 0) {

            numberOfOneSeater++;
            numberOfTwoSeater--;
            sum++;
        }

        else if (groups[index] != 1 && numberOfTwoSeater > 0) {

            numberOfTwoSeater--;
            sum += 2
        }
    }

    for (let index = 0; index < numberOfGroups; index++) {

         totalSum += parseInt(groups[index]);
    }

    console.log(totalSum - sum);
}

/**
 *
In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them,
it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person.
 If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input
The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant,
the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order.
 If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output
Print the total number of people the restaurant denies service to.

Examples
input
4 1 2
1 2 1 1
output
0
input
4 1 1
1 1 2 1
output
2
Note
In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table.
The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person,
 he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person,
it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them.
The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let numberOfGroups = inputString[0].split(" ")[0];
    let numberOfOneSeater = inputString[0].split(" ")[1];
    let numberOfTwoSeater = inputString[0].split(" ")[2];
    let groups = inputString[1].split(" ")

    solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups)

});

function solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups) {

    let sum = 0 ;
    for (let index = 0; index < Number(numberOfGroups); index++) {

        /**
 *
In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them,
it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person.
 If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input
The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant,
the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order.
 If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output
Print the total number of people the restaurant denies service to.

Examples
input
4 1 2
1 2 1 1
output
0
input
4 1 1
1 1 2 1
output
2
Note
In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table.
The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person,
 he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person,
it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them.
The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let numberOfGroups = inputString[0].split(" ")[0];
    let numberOfOneSeater = inputString[0].split(" ")[1];
    let numberOfTwoSeater = inputString[0].split(" ")[2];
    let groups = inputString[1].split(" ")

    solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups)

});

function solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups) {

    let sum = 0 ;
    for (let index = 0; index < Number(numberOfGroups); index++) {

        if (Number(groups[index]) == 1 && Number(numberOfOneSeater) > 0) {
            numberOfOneSeater--;
            groups[index] = 0 ;
        }

        if(Number(groups[index]) == 1 && Number(numberOfOneSeater) == 0 && Number(numberOfTwoSeater) > 0){

            numberOfOneSeater++;
            numberOfTwoSeater--;
            groups[index] = 0;
        }

        else if (Number(groups[index]) != 1 && Number(numberOfTwoSeater) > 0) {
            numberOfTwoSeater--;
            groups[index] = 0 ;
        }
    }

    for(let index = 0 ; index < Number(numberOfGroups) ; index ++){

        sum += Number(groups[index])
    }

    console.log(sum)
}
        if (Number(groups[index]) == 1 && Number(numberOfOneSeater) > 0) {
            numberOfOneSeater--;
            groups[index] = 0 ;
        }

        else if (Number(groups[index]) != 1 && Number(numberOfTwoSeater) > 0) {
            numberOfTwoSeater--;
            groups[index] = 0 ;
        }
    }

    for(let index = 0 ; index < Number(numberOfGroups) ; index ++){

        sum += Number(groups[index])
    }

    console.log(sum)
}

/**
 *
In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them,
it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person.
 If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input
The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant,
the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order.
 If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output
Print the total number of people the restaurant denies service to.

Examples
input
4 1 2
1 2 1 1
output
0
input
4 1 1
1 1 2 1
output
2
Note
In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table.
The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person,
 he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person,
it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them.
The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let numberOfGroups = Number(inputString[0].split(" ")[0]);
    let numberOfOneSeater = Number(inputString[0].split(" ")[1]);
    let numberOfTwoSeater = Number(inputString[0].split(" ")[2]);
    let groups = inputString[1].split(" ")

    solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups)

});

function solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups) {

    let sum = 0;

    for (let index = 0; index < numberOfGroups; index++) {

        if (groups[index] == 1 && numberOfOneSeater > 0) {

            numberOfOneSeater--;
            groups[index] = 0;
        }

        else if (groups[index] == 1 && !numberOfOneSeater  && numberOfTwoSeater > 0) {

            numberOfOneSeater++;
            numberOfTwoSeater -= 2;
            groups[index] = 0;
        }

        else if (groups[index] > 0 && groups[index] != 1 && numberOfTwoSeater > 0) {

            numberOfTwoSeater -= 2;
            groups[index] = 0;
        }
    }

    for (let index = 0; index < numberOfGroups; index++) {

        sum += parseInt(groups[index]);
    }

    console.log(sum);
}

/**
 *
In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them,
it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person.
 If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input
The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant,
the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order.
 If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output
Print the total number of people the restaurant denies service to.

Examples
input
4 1 2
1 2 1 1
output
0
input
4 1 1
1 1 2 1
output
2
Note
In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table.
The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person,
 he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person,
it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them.
The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let numberOfGroups = inputString[0].split(" ")[0];
    let numberOfOneSeater = inputString[0].split(" ")[1];
    let numberOfTwoSeater = inputString[0].split(" ")[2];
    let groups = inputString[1].split(" ")

    solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups)

});

function solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups) {

    let sum = 0 ;
    for (let index = 0; index < numberOfGroups; index++) {

        if (Number(groups[index]) == 1 && numberOfOneSeater > 0) {
            numberOfOneSeater--;
            groups[index] = 0
        }

        else if(Number(groups[index]) == 1 && numberOfOneSeater == 0 && numberOfTwoSeater > 0){

            numberOfOneSeater++;
            numberOfTwoSeater--;
            groups[index] = 0
        }

        else if (Number(groups[index]) != 1 && numberOfTwoSeater > 0) {
            numberOfTwoSeater--;
            groups[index] = 0
        }

        if (Number(groups[index]) != 1 && numberOfTwoSeater ==0) {
            groups[index] = 2
        }
    }

    for(let index = 0 ; index < numberOfGroups ; index ++){

        sum += Number(groups[index])
    }

    console.log(sum)
}

/**
 *
In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them,
it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person.
 If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input
The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant,
the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order.
 If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output
Print the total number of people the restaurant denies service to.

Examples
input
4 1 2
1 2 1 1
output
0
input
4 1 1
1 1 2 1
output
2
Note
In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table.
The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person,
 he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person,
it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them.
The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let numberOfGroups = inputString[0].split(" ")[0];
    let numberOfOneSeater = inputString[0].split(" ")[1];
    let numberOfTwoSeater = inputString[0].split(" ")[2];
    let groups = inputString[1].split(" ")

    solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups)

});

function solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups) {

    let sum = 0 ;
    for (let index = 0; index < Number(numberOfGroups); index++) {

        if (Number(groups[index]) == 1 && Number(numberOfOneSeater) > 0) {
            numberOfOneSeater--;
            groups[index] = 0 ;
        }

        else if(Number(groups[index]) == 1 && Number(numberOfOneSeater) == 0 && Number(numberOfTwoSeater) > 0){

            numberOfOneSeater++;
            numberOfTwoSeater--;
            groups[index] = 0;
        }

        else if (Number(groups[index]) != 1 && Number(numberOfTwoSeater) > 0) {
            numberOfTwoSeater--;
            groups[index] = 0
        }
    }

    for(let index = 0 ; index < Number(numberOfGroups) ; index ++){

        sum += Number(groups[index])
    }

    console.log(sum)
}

/**
 *
In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them,
it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person.
 If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input
The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant,
the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order.
 If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output
Print the total number of people the restaurant denies service to.

Examples
input
4 1 2
1 2 1 1
output
0
input
4 1 1
1 1 2 1
output
2
Note
In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table.
The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person,
 he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person,
it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them.
The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let numberOfGroups = Number(inputString[0].split(" ")[0]);
    let numberOfOneSeater = Number(inputString[0].split(" ")[1]);
    let numberOfTwoSeater = Number(inputString[0].split(" ")[2]);
    let groups = inputString[1].split(" ")

    solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups)

});

function solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups) {

    let sum = 0;
    for (let index = 0; index < numberOfGroups; index++) {

        if (groups[index] == 1 && numberOfOneSeater > 0) {

            numberOfOneSeater--;
            groups[index] = 0;
        }

        else if (groups[index] == 1 && !numberOfOneSeater  && numberOfTwoSeater > 0) {

            numberOfOneSeater++;
            numberOfTwoSeater--;
            groups[index] = 0;
        }

        else if (groups[index] == 2 && numberOfTwoSeater > 0) {

            numberOfTwoSeater--;
            groups[index] = 0;
        }
    }

    for (let index = 0; index < numberOfGroups; index++) {

        sum += parseInt(groups[index]);
    }

    console.log(sum);
}

/**
 *
In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them,
it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person.
 If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input
The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant,
the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order.
 If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output
Print the total number of people the restaurant denies service to.

Examples
input
4 1 2
1 2 1 1
output
0
input
4 1 1
1 1 2 1
output
2
Note
In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table.
The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person,
 he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person,
it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them.
The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let numberOfGroups = inputString[0].split(" ")[0];
    let numberOfOneSeater = inputString[0].split(" ")[1];
    let numberOfTwoSeater = inputString[0].split(" ")[2];
    let groups = inputString[1].split(" ")

    solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups)

});

function solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups) {

    let sum = 0 ;
    for (let index = 0; index < numberOfGroups; index++) {

        if (Number(groups[index]) == 1 && Number(numberOfOneSeater) > 0) {
            numberOfOneSeater--;
            groups[index] = 0
        }

        else if(Number(groups[index]) == 1 && Number(numberOfOneSeater) == 0 && Number(numberOfTwoSeater) > 0){

            numberOfOneSeater++;
            numberOfTwoSeater--;
            groups[index] = 0
        }

        else if (Number(groups[index]) != 1 && Number(numberOfTwoSeater) > 0) {
            numberOfTwoSeater--;
            groups[index] = 0
        }
    }

    for(let index = 0 ; index < numberOfGroups ; index ++){

        sum += Number(groups[index])
    }

    console.log(sum)
}

/**
 *
In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them,
it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person.
 If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input
The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant,
the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order.
 If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output
Print the total number of people the restaurant denies service to.

Examples
input
4 1 2
1 2 1 1
output
0
input
4 1 1
1 1 2 1
output
2
Note
In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table.
The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person,
 he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person,
it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them.
The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let numberOfGroups = inputString[0].split(" ")[0];
    let numberOfOneSeater = inputString[0].split(" ")[1];
    let numberOfTwoSeater = inputString[0].split(" ")[2];
    let groups = inputString[1].split(" ")

    solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups)

});

function solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups) {

    let sum = 0 ;
    for (let index = 0; index < Number(numberOfGroups); index++) {

        if (Number(groups[index]) == 1 && Number(numberOfOneSeater) > 0) {
            numberOfOneSeater--;
        }

        else if(Number(groups[index]) == 1 && Number(numberOfOneSeater) == 0 && Number(numberOfTwoSeater) > 0){

            numberOfOneSeater++;
            numberOfTwoSeater--;
        }

        else if (Number(groups[index]) != 1 && Number(numberOfTwoSeater) > 0) {
            numberOfTwoSeater--;
        }

        else if(Number(groups[index]) == 1 && Number(numberOfOneSeater) == 0 && Number(numberOfTwoSeater) == 0){

            sum++
         }

         else if(Number(groups[index]) != 1 && Number(numberOfTwoSeater) == 0){

            sum +=2
         }
    }
    console.log(sum)
}

/**
 *
In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them,
it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person.
 If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input
The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant,
the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order.
 If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output
Print the total number of people the restaurant denies service to.

Examples
input
4 1 2
1 2 1 1
output
0
input
4 1 1
1 1 2 1
output
2
Note
In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table.
The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person,
 he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person,
it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them.
The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let numberOfGroups = Number(inputString[0].split(" ")[0]);
    let numberOfOneSeater = Number(inputString[0].split(" ")[1]);
    let numberOfTwoSeater = Number(inputString[0].split(" ")[2]);
    let groups = inputString[1].split(" ")

    solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups)

});

function solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups) {

    let sum = 0;
    for (let index = 0; index < numberOfGroups; index++) {

        if (groups[index] == 1 && numberOfOneSeater > 0) {

            numberOfOneSeater--;
            groups[index] = 0;
        }

        else if (groups[index] == 1 && !numberOfOneSeater  && numberOfTwoSeater > 0) {

            numberOfOneSeater++;
            numberOfTwoSeater--;
            groups[index] = 0;
        }

        else if (groups[index] > 0 && groups[index] != 1  && numberOfTwoSeater > 0) {

            numberOfTwoSeater--;
            groups[index] = 0;
        }
    }

    for (let index = 0; index < numberOfGroups; index++) {

        sum += parseInt(groups[index]);
    }

    console.log(sum);
}

/**
 *
In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them,
it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person.
 If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input
The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant,
the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order.
 If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output
Print the total number of people the restaurant denies service to.

Examples
input
4 1 2
1 2 1 1
output
0
input
4 1 1
1 1 2 1
output
2
Note
In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table.
The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person,
 he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person,
it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them.
The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let numberOfGroups = inputString[0].split(" ")[0];
    let numberOfOneSeater = inputString[0].split(" ")[1];
    let numberOfTwoSeater = inputString[0].split(" ")[2];
    let groups = inputString[1].split(" ")

    solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups)

});

function solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups) {

    let sum = 0 ;
    for (let index = 0; index < numberOfGroups; index++) {

        if (Number(groups[index]) == 1 && numberOfOneSeater > 0) {
            numberOfOneSeater--;
            groups[index] = 0
        }

        else if(Number(groups[index]) == 1 && numberOfOneSeater == 0 && numberOfTwoSeater > 0){

            numberOfOneSeater++;
            numberOfTwoSeater--;
            groups[index] = 0
        }

        else if (Number(groups[index]) != 1 && numberOfTwoSeater > 0) {
            numberOfTwoSeater--;
            groups[index] = 0
        }

        else if (Number(groups[index]) != 1 && numberOfTwoSeater ==0) {
            groups[index] = 2
        }
    }

    for(let index = 0 ; index < numberOfGroups ; index ++){

        sum += Number(groups[index])
    }

    console.log(sum)
}

/**
 *
In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them,
it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person.
 If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input
The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant,
the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order.
 If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output
Print the total number of people the restaurant denies service to.

Examples
input
4 1 2
1 2 1 1
output
0
input
4 1 1
1 1 2 1
output
2
Note
In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table.
The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person,
 he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person,
it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them.
The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let numberOfGroups = inputString[0].split(" ")[0];
    let numberOfOneSeater = inputString[0].split(" ")[1];
    let numberOfTwoSeater = inputString[0].split(" ")[2];
    let groups = inputString[1].split(" ")

    solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups)

});

function solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups) {

    let sum = 0 ;
    for (let index = 0; index < Number(numberOfGroups); index++) {

        if (Number(groups[index]) == 1 && Number(numberOfOneSeater) > 0) {
            numberOfOneSeater--;
            groups[index] = 0
        }

        else if(Number(groups[index]) == 1 && Number(numberOfOneSeater) == 0 && Number(numberOfTwoSeater) > 0){

            numberOfOneSeater++;
            numberOfTwoSeater--;
            groups[index] = 0
        }

        else if (Number(groups[index]) != 1 && Number(numberOfTwoSeater) > 0) {
            numberOfTwoSeater--;
            groups[index] = 0
        }
    }

    for(let index = 0 ; index < Number(numberOfGroups) ; index ++){

        sum += Number(groups[index])
    }

    console.log(sum)
}

/**
 *
In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them,
it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person.
 If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input
The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant,
the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order.
 If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output
Print the total number of people the restaurant denies service to.

Examples
input
4 1 2
1 2 1 1
output
0
input
4 1 1
1 1 2 1
output
2
Note
In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table.
The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person,
 he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person,
it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them.
The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let numberOfGroups = Number(inputString[0].split(" ")[0]);
    let numberOfOneSeater = Number(inputString[0].split(" ")[1]);
    let numberOfTwoSeater = Number(inputString[0].split(" ")[2]);
    let groups = inputString[1].split(" ")

    solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups)

});

function solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups) {

    let sum = 0;
    for (let index = 0; index < numberOfGroups; index++) {

        if (groups[index] == 1 && numberOfOneSeater > 0) {

            numberOfOneSeater--;
            groups[index] = 0;
        }

        else if (groups[index] == 1 && !numberOfOneSeater && numberOfTwoSeater > 0) {

            numberOfOneSeater++;
            numberOfTwoSeater--;
            groups[index] = 0;
        }

        else if (groups[index] != 1 && numberOfTwoSeater > 0) {

            numberOfTwoSeater--;
            groups[index] = 0;
        }
    }

    sum = function(arr){
        return arr.reduce(function(a,b){
          return a + b
        }, 0);
      }

    console.log(sum);
}

/**
 *
In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them,
it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person.
 If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input
The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant,
the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order.
 If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output
Print the total number of people the restaurant denies service to.

Examples
input
4 1 2
1 2 1 1
output
0
input
4 1 1
1 1 2 1
output
2
Note
In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table.
The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person,
 he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person,
it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them.
The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let numberOfGroups = inputString[0].split(" ")[0];
    let numberOfOneSeater = inputString[0].split(" ")[1];
    let numberOfTwoSeater = inputString[0].split(" ")[2];
    let groups = inputString[1].split(" ")

    solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups)

});

function solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups) {

    let sum = 0 ;
    for (let index = 0; index < Number(numberOfGroups); index++) {

        if (Number(groups[index]) == 1 && Number(numberOfOneSeater) > 0) {
            numberOfOneSeater--;
            groups[index] = 0 ;
        }

        else if(Number(groups[index]) == 1 && Number(numberOfOneSeater) == 0 && Number(numberOfTwoSeater) > 0){

            numberOfOneSeater++;
            numberOfTwoSeater--;
            groups[index] = 0;
        }

        else if (Number(groups[index]) != 1 && Number(numberOfTwoSeater) > 0) {
            numberOfTwoSeater--;
            groups[index] = 0 ;
        }
    }

    for(let index = 0 ; index < Number(numberOfGroups) ; index ++){

        sum += Number(groups[index])
    }

    console.log(sum)
}

/**
 *
In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them,
it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person.
 If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input
The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant,
the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order.
 If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output
Print the total number of people the restaurant denies service to.

Examples
input
4 1 2
1 2 1 1
output
0
input
4 1 1
1 1 2 1
output
2
Note
In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table.
The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person,
 he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person,
it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them.
The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let numberOfGroups = Number(inputString[0].split(" ")[0]);
    let numberOfOneSeater = Number(inputString[0].split(" ")[1]);
    let numberOfTwoSeater = Number(inputString[0].split(" ")[2]);
    let groups = inputString[1].split(" ")

    solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups)

});

function solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups) {

    let sum = 0;
    for (let index = 0; index < numberOfGroups; index++) {

        if (groups[index] == 1 && numberOfOneSeater > 0) {

            numberOfOneSeater--;
            groups[index] = 0;
        }

        else if (groups[index] == 1 && numberOfOneSeater == 0 && numberOfTwoSeater > 0) {

            numberOfOneSeater++;
            numberOfTwoSeater--;
            groups[index] = 0;
        }

        else if (groups[index] != 1 && numberOfTwoSeater > 0) {

            numberOfTwoSeater--;
            groups[index] = 0;
        }
    }

    for (let index = 0; index < numberOfGroups; index++) {

        sum += Number(groups[index]);
    }

    console.log(sum);
}

/**
 *
In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them,
it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person.
 If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input
The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant,
the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order.
 If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output
Print the total number of people the restaurant denies service to.

Examples
input
4 1 2
1 2 1 1
output
0
input
4 1 1
1 1 2 1
output
2
Note
In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table.
The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person,
 he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person,
it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them.
The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let numberOfGroups = inputString[0].split(" ")[0];
    let numberOfOneSeater = inputString[0].split(" ")[1];
    let numberOfTwoSeater = inputString[0].split(" ")[2];
    let groups = inputString[1].split(" ")

    solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups)

});

function solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups) {

    let sum = 0 ;
    for (let index = 0; index < Number(numberOfGroups); index++) {

        if (Number(groups[index]) == 1 && Number(numberOfOneSeater) > 0) {
            numberOfOneSeater--;
        }

        else if(Number(groups[index]) == 1 && Number(numberOfOneSeater) == 0 && Number(numberOfTwoSeater) > 0){

            numberOfOneSeater++;
            numberOfTwoSeater--;
        }

        else if (Number(groups[index]) != 1 && Number(numberOfTwoSeater) > 0) {
            numberOfTwoSeater--;
        }

        else if(Number(groups[index]) == 1 && Number(numberOfOneSeater) == 0 && Number(numberOfTwoSeater) == 0){

            sum++
         }

         else if(Number(groups[index]) != 2 && Number(numberOfTwoSeater) == 0){

            sum +=2
         }
    }
    console.log(sum)
}

/**
 *
In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them,
it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person.
 If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input
The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant,
the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order.
 If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output
Print the total number of people the restaurant denies service to.

Examples
input
4 1 2
1 2 1 1
output
0
input
4 1 1
1 1 2 1
output
2
Note
In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table.
The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person,
 he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person,
it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them.
The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let numberOfGroups = Number(inputString[0].split(" ")[0]);
    let numberOfOneSeater = Number(inputString[0].split(" ")[1]);
    let numberOfTwoSeater = Number(inputString[0].split(" ")[2]);
    let groups = inputString[1].split(" ")

    solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups)

});

function solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups) {

    let sum = 0;
    for (let index = 0; index < numberOfGroups; index++) {

        if (groups[index] == 1 && numberOfOneSeater > 0) {

            numberOfOneSeater--;
            groups[index] = 0;
        }

        else if (groups[index] == 1 && numberOfOneSeater == 0 && numberOfTwoSeater > 0) {

            numberOfOneSeater += 2;
            numberOfTwoSeater--;
            groups[index] = 0;
        }

        else if (groups[index] != 1 && numberOfTwoSeater > 0) {

            numberOfTwoSeater--;
            groups[index] = 0;
        }
    }

    for (let index = 0; index < numberOfGroups; index++) {

        sum += groups[index];
    }

    console.log(sum);
}

/**
 *
In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them,
it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person.
 If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input
The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant,
the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order.
 If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output
Print the total number of people the restaurant denies service to.

Examples
input
4 1 2
1 2 1 1
output
0
input
4 1 1
1 1 2 1
output
2
Note
In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table.
The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person,
 he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person,
it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them.
The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let numberOfGroups = Number(inputString[0].split(" ")[0]);
    let numberOfOneSeater = Number(inputString[0].split(" ")[1]);
    let numberOfTwoSeater = Number(inputString[0].split(" ")[2]);
    let groups = inputString[1].split(" ")

    solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups)

});

function solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups) {

    let sum = 0;
    let numberOfTwoSeaterOccupiedByOnePerson = 0;

    for (let index = 0; index < numberOfGroups; index++) {

        if (groups[index] == 1 && numberOfOneSeater > 0) {

            numberOfOneSeater--;
            groups[index] = 0;
        }

        else if (groups[index] == 1 && !numberOfOneSeater  && numberOfTwoSeater > 0) {

            numberOfTwoSeaterOccupiedByOnePerson++;
            numberOfTwoSeater--;
        }

        if (groups[index] == 1 && !numberOfOneSeater && numberOfTwoSeaterOccupiedByOnePerson > 0) {

            numberOfTwoSeaterOccupiedByOnePerson--;
            groups[index] = 0 ;
        }

        else if (groups[index] > 0 && groups[index] != 1  && numberOfTwoSeater > 0) {

            numberOfTwoSeater--;
            groups[index] = 0;
        }
    }

    for (let index = 0; index < numberOfGroups; index++) {

        sum += parseInt(groups[index]);
    }

    console.log(sum);
}

/**
 *
In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them,
it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person.
 If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input
The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant,
the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order.
 If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output
Print the total number of people the restaurant denies service to.

Examples
input
4 1 2
1 2 1 1
output
0
input
4 1 1
1 1 2 1
output
2
Note
In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table.
The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person,
 he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person,
it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them.
The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let numberOfGroups = Number(inputString[0].split(" ")[0]);
    let numberOfOneSeater = Number(inputString[0].split(" ")[1]);
    let numberOfTwoSeater = Number(inputString[0].split(" ")[2]);
    let groups = inputString[1].split(" ")

    solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups)

});

function solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups) {

    let sum = 0;
    let oldNumberOfOneSeater = numberOfOneSeater;
    for (let index = 0; index < numberOfGroups; index++) {

        if (groups[index] == 1 && numberOfOneSeater > 0) {

            oldNumberOfOneSeater = numberOfOneSeater;
            numberOfOneSeater--;
            groups[index] = 0;
        }

        else if (groups[index] == 1 && !numberOfOneSeater && oldNumberOfOneSeater > 1 && numberOfTwoSeater > 0) {

            numberOfOneSeater++;
            numberOfTwoSeater--;
            groups[index] = 0;
        }

        else if (groups[index] != 1 && numberOfTwoSeater > 0) {

            numberOfTwoSeater--;
            groups[index] = 0;
        }
    }

    for (let index = 0; index < numberOfGroups; index++) {

        sum += parseInt(groups[index]);
    }

    console.log(sum);
}

/**
 *
In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them,
it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person.
 If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input
The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant,
the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order.
 If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output
Print the total number of people the restaurant denies service to.

Examples
input
4 1 2
1 2 1 1
output
0
input
4 1 1
1 1 2 1
output
2
Note
In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table.
The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person,
 he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person,
it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them.
The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let numberOfGroups = Number(inputString[0].split(" ")[0]);
    let numberOfOneSeater = Number(inputString[0].split(" ")[1]);
    let numberOfTwoSeater = Number(inputString[0].split(" ")[2]);
    let groups = inputString[1].split(" ")

    solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups)

});

function solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups) {

    let sum = 0;
    for (let index = 0; index < numberOfGroups; index++) {

        if (groups[index] == 1 && numberOfOneSeater > 0) {

            numberOfOneSeater--;
            groups[index] = 0;
        }

        else if (groups[index] == 1 && !numberOfOneSeater && numberOfTwoSeater > 0) {

            numberOfOneSeater++;
            numberOfTwoSeater--;
            groups[index] = 0;
        }

        else if (groups[index] != 1 && numberOfTwoSeater > 0) {

            numberOfTwoSeater--;
            groups[index] = 0;
        }
    }

    for (let index = 0; index < numberOfGroups; index++) {

        sum += parseInt(groups[index]);
    }

    console.log(sum);
}

/**
 *
In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them,
it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person.
 If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input
The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant,
the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order.
 If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output
Print the total number of people the restaurant denies service to.

Examples
input
4 1 2
1 2 1 1
output
0
input
4 1 1
1 1 2 1
output
2
Note
In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table.
The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person,
 he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person,
it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them.
The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let numberOfGroups = Number(inputString[0].split(" ")[0]);
    let numberOfOneSeater = Number(inputString[0].split(" ")[1]);
    let numberOfTwoSeater = Number(inputString[0].split(" ")[2]);
    let groups = inputString[1].split(" ")

    solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups)

});

function solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups) {

    let sum = 0;

    for (let index = 0; index < numberOfGroups; index++) {

        if (groups[index] == 1 && numberOfOneSeater > 0) {

            numberOfOneSeater--;
            groups[index] = 0;
        }

        else if (groups[index] == 1 && !numberOfOneSeater  && numberOfTwoSeater > 0) {

            numberOfTwoSeater--;
            groups[index] = 0;
        }

        else if (groups[index] > 0 && groups[index] != 1 && numberOfTwoSeater > 0) {

            numberOfTwoSeater--;
            groups[index] = 0;
        }

    }

    for (let index = 0; index < numberOfGroups; index++) {

        sum += parseInt(groups[index]);
    }

    console.log(sum);
}

/**
 *
In a small restaurant there are a tables for one person and b tables for two persons.

It it known that n groups of people come today, each consisting of one or two people.

If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them,
it is seated at a vacant two-seater table. If there are none of them, it is seated at a two-seater table occupied by single person.
 If there are still none of them, the restaurant denies service to this group.

If a group consist of two people, it is seated at a vacant two-seater table. If there are none of them, the restaurant denies service to this group.

You are given a chronological order of groups coming. You are to determine the total number of people the restaurant denies service to.

Input
The first line contains three integers n, a and b (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ 2·105) — the number of groups coming to the restaurant,
the number of one-seater and the number of two-seater tables.

The second line contains a sequence of integers t1, t2, ..., tn (1 ≤ ti ≤ 2) — the description of clients in chronological order.
 If ti is equal to one, then the i-th group consists of one person, otherwise the i-th group consists of two people.

Output
Print the total number of people the restaurant denies service to.

Examples
input
4 1 2
1 2 1 1
output
0
input
4 1 1
1 1 2 1
output
2
Note
In the first example the first group consists of one person, it is seated at a vacant one-seater table. The next group occupies a whole two-seater table.
The third group consists of one person, it occupies one place at the remaining two-seater table. The fourth group consists of one person,
 he is seated at the remaining seat at the two-seater table. Thus, all clients are served.

In the second example the first group consists of one person, it is seated at the vacant one-seater table. The next group consists of one person,
it occupies one place at the two-seater table. It's impossible to seat the next group of two people, so the restaurant denies service to them.
The fourth group consists of one person, he is seated at the remaining seat at the two-seater table. Thus, the restaurant denies service to 2 clients.
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let numberOfGroups = inputString[0].split(" ")[0];
    let numberOfOneSeater = inputString[0].split(" ")[1];
    let numberOfTwoSeater = inputString[0].split(" ")[2];
    let groups = inputString[1].split(" ")

    solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups)

});

function solution(numberOfGroups, numberOfOneSeater, numberOfTwoSeater, groups) {

    let sum = 0 ;
    let numberOfTwoSeaterOccupiedByOnePerson = 0;
    for (let index = 0; index < Number(numberOfGroups); index++) {

        if (Number(groups[index]) == 1 && Number(numberOfOneSeater) > 0) {
            numberOfOneSeater--;
            groups[index] = 0 ;
        }

        else if(Number(groups[index]) == 1 && Number(numberOfOneSeater) == 0 && Number(numberOfTwoSeater) > 0){

            numberOfTwoSeaterOccupiedByOnePerson++;
            numberOfTwoSeater--;
         //   groups[index] = 0;
        }

        else if(Number(groups[index]) == 1 && Number(numberOfTwoSeaterOccupiedByOnePerson) > 0 ){
            numberOfTwoSeaterOccupiedByOnePerson--;
            groups[index] = 0;

        }

        else if (Number(groups[index]) != 1 && Number(numberOfTwoSeater) > 0) {
            numberOfTwoSeater--;
            groups[index] = 0 ;
        }
    }

    for(let index = 0 ; index < Number(numberOfGroups) ; index ++){

        sum += Number(groups[index])
    }

    console.log(sum)
}

var data = readline().split(' ').map(function (x) { return parseInt(x); });
var guests = readline().split(' ').map(function (x) { return parseInt(x); });

var sTable = data[1];
var dTable = data[2];

var total = guests.reduce(function (a,b) {
  return parseInt(a)+parseInt(b);
}, 0);

for (var g of guests) {
 if (g === 2) {
   if (dTable > 0) {
     dTable--;
     total -= g;
   }
 }
 if (g === 1) {
   if (sTable > 0) {
     sTable--;
     total -= g;
   } else if (dTable > 0) {
     dTable--;
     sTable++;
     total -= g;
   }
 }

}

print(total);

function GetAns(n, a, b, array){
	var ans=0;
	var tOne, tTwo, tTwoWithOne;
	tOne = a; tTwo = b; tTwoWithOne = 0;
	for (var i=0;i<n;i++){
		if ((+array[i])===2){
			if (tTwo>0)
				tTwo--;
			else
				ans+=2;
		}
		else{
			if (tOne>0)
				tOne--;
			else{
				if (tTwoWithOne>0) tTwoWithOne--;
				else
					if (tTwo>0){
						tTwo--;
						tTwoWithOne++;
					}
					else
						ans++;
			}
		}
	}
	return ans;
}

var input = readline().split(' ');
var n=+input[0], a=+input[1], b=+input[2];
var array=readline().split(' ');
print(GetAns(n,a,b,array));