fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val n = sc.nextInt()
    val a = sc.asSequence().take(n + 1).map { it.toInt() }.toMutableList()
    val b = sc.asSequence().take(n).map { it.toInt() }.toMutableList()

    var r = 0L
    for (i in 0 until n) {
        val score = Math.min(a[i], b[i])
        b[i] -= score
        val scoreNext = Math.min(a[i + 1], b[i])
        a[i + 1] -= scoreNext
        r += score + scoreNext
    }
    println(r)
}
