function main(input)
{
    const args = input.split('\n');
    const houses = args[1].split(' ').map(x => parseInt(x, 10));
    const heros = args[2].split(' ').map(x => parseInt(x, 10));
    // console.log(houses);
    // console.log(heros);

    var answerCount = 0;

    for (var i = 0; i < heros.length; i++)
    {
    	var enemyCount = houses[i] + houses[i + 1];
    	var killCount = Math.min(enemyCount, heros[i]);
        answerCount += killCount;

        houses[i + 1] = houses[i + 1] - 
          Math.max(killCount - houses[i], 0);
    }
    console.log(answerCount);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
