import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  val a = List.fill(n + 1)(sc.nextLong)
  val b = List.fill(n)(sc.nextLong)

  // immutableにしたい

  def test(a: List[Long], b: List[Long]): Long = {
    (a, b) match {
      case (_ :: Nil, Nil) => 0
      case (aFirst :: aRest, bFirst :: bRest) if bFirst <= aFirst => bFirst + test(aRest, bRest)
      case (aFirst :: aSecond :: aRest, bFirst :: bRest) =>
        if (aFirst + aSecond <= bFirst) aFirst + aSecond + test(0 :: aRest, bRest)
        else if (aFirst + aSecond <= bFirst) aFirst + aSecond + test(0 :: aRest, bRest)
        else if (bFirst <= aFirst + aSecond) bFirst + test(aSecond + (aFirst - bFirst) :: aRest, bRest)
        else bFirst + test(aSecond + (aFirst - bFirst) :: aRest, bRest)
//      case (aFirst :: aSecond :: aRest, bFirst :: bRest) if aFirst + aSecond <= bFirst => aFirst + aSecond + test(0 :: aRest, bRest)
//      case (aFirst :: aSecond :: aRest, bFirst :: bRest) if bFirst <= aFirst + aSecond =>  bFirst + test(aSecond + (aFirst - bFirst) :: aRest, bRest)
//      case (aFirst :: aSecond :: aRest, bFirst :: bRest) if bFirst <= aFirst + aSecond =>  bFirst + test(aSecond + (aFirst - bFirst) :: aRest, bRest)
    }
  }

  println(test(a, b))

  ///////////////////////////////////////////

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}