object Main extends App {
  val n = readInt
  val monsters = readLine.split(" ").map(_.toInt)
  val savers = readLine.split(" ").map(_.toInt)
  var sum = 0
  var prev_saver = 0
  (0 to n-1).foreach{i=>
    val monster = monsters(i)
    val saver = savers(i)
    if(monster > prev_saver+saver){
      sum += prev_saver+saver
      prev_saver = 0
    }else if(monster > prev_saver){
      sum += monster
      prev_saver = saver + prev_saver - monster
    }else{
      sum += monster
      prev_saver = saver - List(monster-prev_saver,0).min
    }
    //println(List(sum,prev_saver))
  }
  println(sum + List(monsters(n),prev_saver).min)
}