fun main(args: Array<String>) = println(run {
    readLine()
    val a = readLine()!!.split(" ").map { it.toLong() }
    val b = readLine()!!.split(" ").map { it.toLong() }

    val result = a.toLongArray()
    for (i in b.indices) {
        val l = Math.min(result[i], b[i])
        val r = Math.min(result[i+1], b[i]-l)
        result[i] -= l
        result[i+1] -= r
    }
    a.sum()-result.sum()
})