
fun main(args:Array<String>) {
    val n = readLine()!!.toInt()
    val monsterList = readLine()!!.split(" ").map { it.toLong() }.toMutableList()
    val yusha = readLine()!!.split(" ").map { it.toLong() }
    var ans = 0L
    for(i in (0 until n)) {
        var minus = Math.min(yusha[i], monsterList[i])
        ans += minus
        if(minus < yusha[i]) {
            minus = yusha[i] - minus
            minus = Math.min(minus, monsterList[i+1])
            ans += minus
            monsterList[i+1] -= minus
        }
    }
    println(ans)
}
