fun main(args: Array<String>)
{
    val n = readInt()
    val a = readNInts().toLongArray()
    val b = readNInts().toLongArray()
    // val a = Array<Int>(n+1, {0})
    // for (i in 0..n) a[i] = tmp[i]

    // tmp = readNInts()
    // val b = Array<Int>(n, {0})
    // for (i in 0..n-1) b[i] = tmp[i]

    var cnt = 0L

    for (i in n-1 downTo 0) {
        if (a[i+1] >= b[i]) {
            cnt += b[i]
            a[i+1] -= b[i]
            b[i] = 0L
        } else {
            cnt += a[i+1]
            b[i] -= a[i+1]
            a[i+1] = 0L

            if (a[i] >= b[i]) {
                cnt += b[i]
                a[i] -= b[i]
            } else {
                cnt += a[i]
                a[i] = 0L
            }
        }
    }

    println(cnt)
}


// Read an integer
// Usage: val a = readInt()
private fun readInt() = readLine()!!.toInt()

// Read N integers separated by " "
// Usage: val (a, b, c) = readNInts()
private fun readNInts() = readLine()!!.split(" ").map(String::toLong)

// Read a string
// Usage: val a = readString()
private fun readString() = readLine()!!
