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

    val sum = A.sum()
    for (i in B.indices) {
        val hero = B[i]
        val monster = A[i]
        when {
            monster < hero -> {
                A[i + 1] = Math.max(A[i + 1] + A[i] - hero, 0)
                A[i] = 0
            }
            monster == hero -> A[i] = 0
            monster > hero -> A[i] = A[i] - hero
        }
    }
    println(sum - A.sum())
}

