object Main extends App {
  import scala.util.control.Breaks

  val n = io.StdIn.readLine.toInt
  val a = io.StdIn.readLine.split(" ").map(_.toInt)
  val b = io.StdIn.readLine.split(" ").map(_.toInt)

  val k = new Breaks

  var s = 0

  for(i <- 0 to n - 1){

    if (a(i) >= b(i) ) {
      s += b(i)
    }
    if (a(i) < b(i)) {
      s += a(i)
      b(i) -= a(i)
      if (a(i+1) >= b(i)) {
        s += b(i)
        a(i+1) -=  b(i)
        k.break
      }else{
        s += a(i+1)
        a(i+1) = 0
      }
    }
  }
  println(s)
}
