fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toLong() }
    val b = readLine()!!.split(" ").map { it.toLong() }
    var stock = Math.max( b[n-1] - a[n], 0)
    var ret = Math.min(b[n-1], a[n])
    for (i in n-1 downTo 1) {
        ret += Math.min(stock + b[i-1], a[i])
        if (a[i] - stock >= 0) {
            stock = Math.max(b[i-1] - (a[i] - stock), 0)
        } else {
            stock = b[i-1]
        }
    }
    ret += Math.min(stock, a[0])
    println(ret)
}