

function Main(input) {
  'use strict';

  const temp = input.split("\n");
  const n = temp.shift();
  const an = temp.shift().split(" ");
  const bn = temp.shift().split(" ");

  let rest = 0;
  let ans = 0;

  for(let i = 0; i < n; i++){
    const monsters = parseInt(an[i]);
    const strength = parseInt(bn[i]) + rest;
    if(monsters <= strength){
      ans += monsters;
      rest = strength - monsters;
    }else{
      ans += strength;
      rest = 0;
    }
  }
  ans += Math.min(rest,parseInt(an[n]))
  console.log(ans)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
