import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val as = Array.fill(n + 1)(sc.nextInt())
    val bs = Array.fill(n)(sc.nextInt())

    var ans = 0
    for (i <- bs.indices) {
      if (as(i) > bs(i)) {
        ans += bs(i)
        as(i) -= bs(i)
        bs(i) = 0
      } else {
        ans += as(i)
        bs(i) -= as(i)
        as(i) = 0

        val m = math.min(as(i + 1), bs(i))
        as(i + 1) -= m
        bs(i) -= m
        ans += m
      }
    }

    println(ans)
  }
}
