import math.{min, max}
object Main extends App {
  val n = io.StdIn.readInt
  val as = io.StdIn.readLine.split(" ").map(_.toInt)
  val bs = io.StdIn.readLine.split(" ").map(_.toInt) 

  val result = rec(0,0,0)
  def rec(index: Int, counts: Int, prev: Int): Int = {
    if (index+1 == n+1) counts+min(prev, as(index))
    else {
      val mCount = as(index)
      val power = bs(index)
      val mSurplus = max(mCount-prev, 0)

      if (mSurplus < power)
        rec(index+1, counts+mCount, power-mSurplus)
      else
        rec(index+1, counts+prev+power, 0)
    }
  }
  println(result)
}