program main
  implicit none
  integer(8) i,kill,N
  integer(8),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)
  kill = 0
  do i = 1,N
    if (A(i) < B(i)) then
      kill = kill + A(i)
      kill = kill + min(A(i+1),B(i)-A(i))
      A(i+1) = A(i+1)-min(A(i+1),B(i)-A(i))
    else
      kill = kill + B(i)
    end if
  end do      
  write(*, *) kill
end program main
