object Main extends App {
  val max = (x:Int,y:Int)=>if(x>y)x else y 
  val min = (x:Int,y:Int)=>if(x<y)x else y 
  val n = readInt
  val as = readLine.split(" ").map(_.toInt)
  val bs = readLine.split(" ").map(_.toInt)
  var rest = 0
  var beat = 0
  Range(0,n).foreach{i=>
    beat += min(as(i)+rest, bs(i))
    rest = max(as(i) - max(bs(i)-rest, 0), 0)
  }
  beat += min(rest, bs(i))
  println(beat)
}