program kadai
implicit none
integer  ::  n
integer,allocatable  ::  a(:)
integer,allocatable  ::  b(:)
integer  ::  i
integer  ::  num
integer  :: ans


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

ans=0
do i=1,n
    num=a(i)+a(i+1)

    if (num>b(i)) then
        num=num-b(i)
        ans=ans+b(i)
        if (num<a(i+1)) then
            a(i+1)=num
            a(i)=0
        else
            a(i)=num-a(i+1)
        end if
    else
        ans=ans+num
        a(i)=0
        a(i+1)=0
    end if

end do

write(*,*) ans

stop

end program kadai