      PROGRAM CitySavers
      IMPLICIT NONE
      integer(16) :: n
      integer(16),allocatable :: a(:),b(:),remB1(:),remB2(:)
      integer(16) :: i,ans=0
      
      
      read*,n
      allocate( a(n+1),b(n),remB1(n),remB2(n) )
      read*,a(1:n+1)
      read*,b(1:n)
      
      
      do i = n,1,-1
        remB1(i) = max( b(i)-a(i+1),0 )
        a(i+1) = a(i+1) - (b(i)-remB1(i))
        
        remB2(i) = max( remB1(i)-a(i),0 )
        a(i) = a(i) - (remB1(i) - remB2(i))
      end do
      
      !print*,a(1:n+1)
      !print*,remB2
      
      print*,sum( b(:) - remB2(:) )
      
      END PROGRAM