n=int(eval(input()))

a=[int(i) for i in input().split()]

b=[int(i) for i in input().split()]

ans=0

for i in range(n):

    m=min(a[i],b[i])

    ans+=m

    a[i]-=m

    b[i]-=m

    m=min(a[i+1],b[i])

    a[i+1]-=m

    b[i]-=m

    ans+=m

print(ans)

        

from sys import stdin,stdout



if __name__=="__main__":

    n=int(stdin.readline())



    a=[int(x) for x in stdin.readline().split()]

    b=[int(x) for x in stdin.readline().split()]



    cnt=0



    for i in range(n):

        if(a[i]>=b[i]):

            cnt+=b[i]

        else:

            cnt+=a[i]

            d=b[i]-a[i]

            cnt+=min(a[i+1],d)

            if(d>a[i+1]):

                a[i+1]=0

            else: a[i+1]-=d

            

    stdout.write(str(cnt)+"\n")

n = int(eval(input()))
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ans = 0
for i in range(n):
    m = min(a[i], b[i])
    ans += m
    a[i] -= m
    b[i] -= m
    m = min(a[i + 1], b[i])
    a[i + 1] -= m
    b[i] -= m
    ans += m
print(ans)

from sys import stdin, stdout

if __name__ == "__main__":
    n = int(stdin.readline())
    a = [int(x) for x in stdin.readline().split()]
    b = [int(x) for x in stdin.readline().split()]
    cnt = 0
    for i in range(n):
        if a[i] >= b[i]:
            cnt += b[i]
        else:
            cnt += a[i]
            d = b[i] - a[i]
            cnt += min(a[i + 1], d)
            if d > a[i + 1]:
                a[i + 1] = 0
            else:
                a[i + 1] -= d
    stdout.write(str(cnt) + "\n")

-n = int(eval(input())) -a = [int(i) for i in input().split()] -b = [int(i) for i in input().split()] -ans = 0 -for i in range(n): -    m = min(a[i], b[i]) -    ans += m -    a[i] -= m -    b[i] -= m -    m = min(a[i + 1], b[i]) -    a[i + 1] -= m -    b[i] -= m -    ans += m -print(ans) +from sys import stdin, stdout + +if __name__ == "__main__": +    n = int(stdin.readline()) +    a = [int(x) for x in stdin.readline().split()] +    b = [int(x) for x in stdin.readline().split()] +    cnt = 0 +    for i in range(n): +        if a[i] >= b[i]: +            cnt += b[i] +        else: +            cnt += a[i] +            d = b[i] - a[i] +            cnt += min(a[i + 1], d) +            if d > a[i + 1]: +                a[i + 1] = 0 +            else: +                a[i + 1] -= d +    stdout.write(str(cnt) + "\n")