"use strict";

const input = require("fs").readFileSync("/dev/stdin", "utf8");
const inputs = input.split("\n");

const N   = Number(inputs[0]);
const As = inputs[1].split(" ").map(Number);
const Bs = inputs[2].split(" ").map(Number);

const main = (N, As, Bs) => {
    let killed = 0;
    // Bs の数字の大きい順に処理

    let remain = As[As.length - 1];
    for (let i = (Bs.length - 1); i >= 0; i--) {
        // 前のループで余ったモンスターの処理を試みる
        if (remain >= Bs[i]) {
            // 全ループのモンスター処理で残勇者0
            killed += Bs[i];
            remain = As[i];
            continue;
        } else {
            // 余力有り
            Bs[i] -= remain;
            killed += remain;
            if (As[i] >= Bs[i]) {
                remain = As[i] - Bs[i];
                killed += Bs[i];
            } else {
                remain = 0;
                killed += As[i];
            }
        }
    }

    return killed;
};
console.log(main(N, As, Bs));