let readInt () = Scanf.scanf " %d" (fun x -> x)
let readInt64 () = Scanf.scanf " %Ld" (fun x -> x)

let (++) = Int64.add
let (--) = Int64.sub
let ( ** ) = Int64.mul
let (//) = Int64.div
let (%%) = Int64.rem

let solve n a b =
  let rec go i best left =
    (*Printf.eprintf "%d %Ld %Ld\n" i best left;*)
    if i = n then best ++ min a.(i) left
    else go (i+1) (best ++ min a.(i) (b.(i) ++ left)) (max 0L (min b.(i) (b.(i) ++ left -- a.(i))))
  in go 0 0L 0L

let main () =
  let n = readInt () in
  let a = Array.init (n+1) (fun _ -> readInt64 ()) in
  let b = Array.init n (fun _ -> readInt64 ()) in
  Printf.printf "%Ld\n" (solve n a b)

let () = main ()
