integer N
integer,allocatable,dimension(:)::A,B
integer ans
read*,N
allocate(A(N+1),B(N))
read*,A
read*,B
ans=0
do i=1,N
  if(A(i)>=B(i))then
    ans=ans+B(i)
  else
    ans=ans+A(i)
    B(i)=B(i)-A(i)
    if(A(i+1)>=B(i))then
      ans=ans+B(I)
      A(i+1)=A(i+1)-B(i)
    else
      ans=ans+A(i+1)
      A(i+1)=0
    endif
  endif
end do

print"(I0)",ans
end