n=io.read("*n")
a={}
b={}

for i=1,n+1 do
  table.insert(a,io.read("*n"))
end

for i=1,n do
  table.insert(b,io.read("*n"))
end

ans=0
for i=1,n do
  if a[i]<b[i] then
    local j=i
    while j<=n and b[i]>0 do
      if a[j]<=b[j] and a[j]~=0 then
        b[j]=b[j]-a[j]
        ans=ans+a[j]
        a[j]=0
      else
        if a[j]~=0 then
          a[j]=a[j]-b[j]
          ans=ans+b[j]
          b[j]=0
          break
        end
      end

      if a[j+1]<=b[j] and a[j+1]~=0 then
        b[j]=b[j]-a[j+1]
        ans=ans+a[j+1]
        a[j+1]=0
      else
        if a[j+1]~=0 then
          a[j+1]=a[j+1]-b[j]
          ans=ans+b[j]
          b[j]=0
          break
        end
      end
      j=j+1
    end
  else
    a[i]=a[i]-b[i]
    ans=ans+b[i]
    b[i]=0
  end
end

print(ans)