fun main(args :Array<String>){
    val N = readLine()!!.toInt()
    val cities = readLine()!!.split(" ").map { it.toInt() }.toMutableList()
    val powers = readLine()!!.split(" ").map { it.toInt() }

    var sum :Long = 0
    for(i in 0..N-1){
      	var p :Int = powers[i]
        val con1 = Math.min(cities[i],p)
        p -= con1
        val con2 = Math.min(cities[i+1],p)
      	cities[i+1] -= con2
		
        sum += con1+con2
    }
    println(sum)
}