program main
  implicit none
  integer :: i, n, atmp, cnt = 0, cnt2 = 0
  integer, allocatable :: a(:), b(:)

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

  do i = 1, n
    atmp = a(i)
    cnt = cnt + min(a(i), b(i))
    a(i) = max(a(i) - b(i), 0)
    b(i) = max(b(i) - atmp, 0)
    cnt = cnt + min(a(i+1), b(i))
    a(i+1) = max(a(i+1) - b(i), 0)
  end do

  do i = n+1, 2
    atmp = a(i)
    cnt2 = cnt2 + min(a(i), b(i-1))
    a(i) = max(a(i) - b(i-1), 0)
    b(i-1) = max(b(i-1) - atmp, 0)
    cnt2 = cnt2 + min(a(i-1), b(i-1))
    a(i+1) = max(a(i-1) - b(i-1), 0)
  end do

  print '(i0)', max(cnt, cnt2)
end program
