program ccc
implicit none

integer :: n, i, sm
integer,allocatable,dimension(:) :: a, b

read*, n
allocate(a(n+1))
allocate(b(n))
read*, a
read*, b

sm=0

do i=1,n
if((a(i))<=(b(i))) then
sm=sm+a(i)
b(i)=b(i)-a(i)
a(i)=0
 if((a(i+1))<=(b(i))) then
 sm=sm+a(i+1)
 a(i+1)=0
 else
 sm=sm+b(i)
 a(i+1)=a(i+1)-b(i)
 end if
else
sm=sm+b(i)
end if
end do

write(*,'(i0)') sm

end program