n = int(eval(input()))

a = list(map(int, input().split()))

b = list(map(int, input().split()))

ans = 0



for i in range(n):

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

    ans += left

    a[i] -= left

    b[i] -= left



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

    ans += right

    a[i+1] -= right

    b[i] -= right



print(ans)

import sys



sys.setrecursionlimit(10 ** 7)

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

    n = int(eval(input()))

    A = list(map(int, input().split()))

    B = list(map(int, input().split()))



    res = 0

    for i in range(n):

        if A[i] <= B[i]:

            res += A[i]

            B[i] -= A[i]

            A[i] = 0



            if A[i + 1] <= B[i]:

                res += A[i + 1]

                B[i] -= A[i + 1]

                A[i + 1] = 0

            else:

                res += B[i]

                A[i + 1] -= B[i]

                B[i] = 0

        else:

            res += B[i]

            A[i] -= B[i]

            B[i] = 0



    print(res)





if __name__ == '__main__':

    resolve()

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

import sys

sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    n = int(eval(input()))
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    res = 0
    for i in range(n):
        if A[i] <= B[i]:
            res += A[i]
            B[i] -= A[i]
            A[i] = 0
            if A[i + 1] <= B[i]:
                res += A[i + 1]
                B[i] -= A[i + 1]
                A[i + 1] = 0
            else:
                res += B[i]
                A[i + 1] -= B[i]
                B[i] = 0
        else:
            res += B[i]
            A[i] -= B[i]
            B[i] = 0
    print(res)


if __name__ == "__main__":
    resolve()

-n = int(eval(input())) -a = list(map(int, input().split())) -b = list(map(int, input().split())) -ans = 0 -for i in range(n): -    left = min(a[i], b[i]) -    ans += left -    a[i] -= left -    b[i] -= left -    right = min(a[i + 1], b[i]) -    ans += right -    a[i + 1] -= right -    b[i] -= right -print(ans) +import sys + +sys.setrecursionlimit(10**7) +f_inf = float("inf") +mod = 10**9 + 7 + + +def resolve(): +    n = int(eval(input())) +    A = list(map(int, input().split())) +    B = list(map(int, input().split())) +    res = 0 +    for i in range(n): +        if A[i] <= B[i]: +            res += A[i] +            B[i] -= A[i] +            A[i] = 0 +            if A[i + 1] <= B[i]: +                res += A[i + 1] +                B[i] -= A[i + 1] +                A[i + 1] = 0 +            else: +                res += B[i] +                A[i + 1] -= B[i] +                B[i] = 0 +        else: +            res += B[i] +            A[i] -= B[i] +            B[i] = 0 +    print(res) + + +if __name__ == "__main__": +    resolve()