object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N: Int = sc.nextInt
  val monsters :List[Int] = List.fill(N + 1)(sc.nextInt)
  val savers :List[Int] = List.fill(N)(sc.nextInt)

  def go(monster: Int, monsters: List[Int], savers :List[Int], sum: Long): Int = savers match {
    case Nil => sum
    case h::t if h < monster => go(monsters.head, monsters.tail, t, sum + h)
    case h::t => go(math.max(0, monsters.head - (h - monster)), monsters.tail, t, sum + math.min(h, monster + monsters.head))
  }
  println(go(monsters.head, monsters.tail, savers, 0))
}
