"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const A = arg[1].split(" ").map(n=>parseInt(n));
    const B = arg[2].split(" ").map(n=>parseInt(n));
    
    const sum = A.reduce((m,n)=>m+n);
    
    let cnt  = 0;
    let rest = 0;
    
    for(let i=0; i<N; i++) {
        let temp = B[i] - A[i];

        if(temp >= A[parseInt(i)+1]) {
            A[parseInt(i)+1] -= temp;
        } else {
            rest += temp;
        }
    }
    console.log(sum - Math.abs(rest));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));