fun main(args:Array<String>) {
    val n = readLine()!!.toInt()
    val monsters =  readLine()!!.split(" ").map{it.toLong()}
    val heroes = readLine()!!.split(" ").map{it.toLong()}
    var result = 0L
    var amari = 0L
    for(i in 0..n){
        val hero = if(i!=n)heroes[i] else 0
        var monster = monsters[i]
        if(amari>=monster){
            result += monster
            amari = hero
            continue
        }else{
            monster -= amari
            result += amari
            amari = 0
        }
        if(hero>=monster){
            result += monster
            amari = hero - monster
        }else{
            result += hero
        }
    }
    println(result)
}