fun main(args: Array<String>) {
//    val mod = 1000000007L
    val mod = 2019
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map(String::toLong).toMutableList()
    val B = readLine()!!.split(" ").map(String::toLong).toList()

    var ans = 0L

    for ((i,b) in B.withIndex()) {
        ans += Math.min(A[i]+A[i+1],b)
        if (b > A[i]) {
            A[i+1] -= b-A[i]
            if (A[i+1] < 0)
                A[i+1] = 0
        }
    }

    println(ans)
}