
object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val a = Array.fill(n+1)(sc.nextLong())
  val b = Array.fill(n)(sc.nextLong()) :+ 0L
  val ans = a.zip(b).foldLeft(0L, 0L)((acc, mh) => {
    val rem = mh._1 - mh._2 - acc._2
    if (rem > 0L) {
      (acc._1 + (mh._1 - rem), 0)
    } else {
      val rem2 = if (mh._1 - acc._2 > 0L) mh._1 - acc._2 else 0L
      (acc._1 + mh._1, mh._2 - rem2)
    }
  })
  println(ans._1)
}
