object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N = sc.nextInt()
  val As = List.fill(N + 1)(sc.nextInt())
  val Bs = List.fill(N)(sc.nextInt()) :+ 0
  val (acc, _) = As.zip(Bs).foldLeft(0 -> 0) {
    case ((acc, diff), (a, b)) =>
      (acc + (diff + b).min(a)) -> (b - (a - diff).max(0)).max(0)
  }
  println(acc)
}
