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
  local s=math.min(a[i], b[i])
  ans=ans+s
  a[i]=a[i]-s
  b[i]=b[i]-s
  if b[i]>0 then
    local s2=math.min(a[i+1], b[i])
    ans=ans+s2
    a[i+1]=a[i+1]-s
    b[i]=b[i]-s2
  end
end

print(ans)