"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);

    let A = arg[1].split(" ").map(n=>parseInt(n));
    const B = arg[2].split(" ").map(n=>parseInt(n));
    
    let sum = A.reduce((m,n)=>m+n);
    
    let answer = 0;
    
    for(let i=0; i<N; i++) {
        if(A[i] >= B[i]) {
            A[i] -= B[i];
        } else {
            let temp = A[i];
            A[i] = 0;
            A[i + 1] = Math.max(0, A[i + 1] - (B[i] - temp));
        }
    }
    
    console.log(sum - A.reduce((m,n)=>m+n));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));