fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(' ').map { it.toLong() }
    val B = readLine()!!.split(' ').map { it.toLong() }
    var rest = LongArray(N)
    var score = LongArray(N + 1)
    for (i in 0 until N + 1) {
        when (i) {
            0 -> {
                if (A[i] < B[i]) {
                    score[i] = A[i]
                    rest[i] = B[i] - A[i]
                } else {
                    score[i] = B[i]
                    rest[i] = 0L
                }
            }
            N -> {
                score[i] = Math.min(A[i], rest[i - 1])
            }
            else -> {
                if ((A[i] - rest[i - 1]) < B[i]) {
                    score[i] = A[i]
                    rest[i] = Math.min(B[i] - A[i] + rest[i - 1], B[i])
                } else {
                    score[i] = B[i] + rest[i - 1]
                    rest[i] = 0L
                }
            }
        }
    }
    var total = 0L
    for (i in 0 until N + 1) {
        total += score[i]
    }
    println(total)
}