program city_savers
  implicit none
  integer :: n, i
  integer(8) :: a(100001) = 0_8, b(100000) = 0_8, c(100001) = 0_8, m1 = 0_8, m2 = 0_8
  read(*,*) n
  read(*,*) a(1:n+1)
  read(*,*) b(1:n)
  c(1:n+1) = a(1:n+1)
  do i = 1, n
    if (b(i) <= c(i)) then
      m1 = m1+b(i)
      cycle
    end if
    if (b(i) <= c(i)+c(i+1)) then
      m1 = m1+b(i)
      c(i+1) = c(i)+c(i+1)-b(i)
      cycle
    end if
    m1 = m1+c(i)+c(i+1)
    c(i+1) = 0_8
  end do
  c(1:n+1) = a(1:n+1)
  do i = n, 1, -1
    if (b(i) <= c(i+1)) then
      m2 = m2+b(i)
      cycle
    end if
    if (b(i) <= c(i)+c(i+1)) then
      m2 = m2+b(i)
      c(i) = c(i)+c(i+1)-b(i)
      cycle
    end if
    m2 = m2+c(i)+c(i+1)
    c(i) = 0_8
  end do
  write(*,'(i0)') max(m1,m2)
  stop
end program city_savers