program main
  implicit none
  integer i,kill1,kill2,N
  integer,allocatable :: A(:),B(:)
  read(*, *) N
  allocate(A(N+1))
  allocate(B(N))
  read(*, *) (A(i), i = 1,N+1)
  read(*, *) (B(i), i = 1,N)

  kill1 = 0
  do i = 1,N
    if (A(i) < B(i)) then
      kill1 = kill1 + A(i)
      kill1 = kill1 + min(A(i+1),B(i)-A(i))
      A(i+1) = A(i+1)-min(A(i+1),B(i)-A(i))
    else
      kill1 = kill1 + B(i)
    end if
  end do

  kill2 = 0
  do i = N,1,-1
    if (A(i+1) < B(i)) then
      kill2 = kill2 + A(i+1)
      kill2 = kill2 + min(A(i),B(i)-A(i+1))
      A(i) = A(i)-min(A(i),B(i)-A(i+1))
    else
      kill2 = kill2 + B(i)
    end if
  end do

  write(*, *) max(kill1,kill2)
end program main
