fun main(args : Array<String>) {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map { it.toInt() }.toIntArray()
    val B = readLine()!!.split(" ").map { it.toInt() }.toIntArray()


    var total = 0L

    (0 until N).forEach {
        var diff = 0
        if (A[it] > 0 && B[it] > 0) {
            if (A[it] - B[it] < 0) {
                diff = A[it]
            } else {
                diff = B[it]
            }

            A[it] -= diff
            B[it] -= diff
            total += diff
        }
        if (A[it+1] > 0 && B[it] > 0) {
            if (A[it+1] - B[it] < 0) {
                diff = A[it+1]
            } else {
                diff = B[it]
            }

            A[it+1] -= diff
            B[it] -= diff
            total += diff
        }
    }
    println(total)
}