program prob1
    implicit none
    integer(8) :: n, i, ans
    integer(8), allocatable :: a(:), b(:)
    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)
            a(i) = a(i) - b(i)
            b(i) = 0
        else
            ans = ans + a(i)
            b(i) = b(i) - a(i)
            a(i) = 0
        end if
        if(a(i+1) >= b(i)) then
            ans = ans + b(i)
            a(i+1) = a(i+1) - b(i)
            b(i) = 0
        else
            ans = ans + a(i+1)
            b(i) = b(i) - a(i+1)
            a(i+1) = 0
        end if
    end do
    write(*,*) ans
        
    stop
contains
end program prob1