import sys

input = sys.stdin.readline



def main():

    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

    print(ans)





if __name__ == "__main__":

    main()
import sys

input = sys.stdin.readline



def main():

    n = int(eval(input()))

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

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



    tmp = 0

    ans = 0

    for i in range(n):

        mon = max(0, a[i] - tmp)



        if b[i] <= mon:

            ans += b[i] + tmp

            tmp = 0

        else:

            ans += a[i]

            tmp = b[i] - mon

            

    if tmp <= a[i + 1]:

        ans += tmp

    else:

        ans += a[i + 1]

    print(ans)



if __name__ == "__main__":

    main()
import sys

input = sys.stdin.readline


def main():
    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
    print(ans)


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline


def main():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    tmp = 0
    ans = 0
    for i in range(n):
        mon = max(0, a[i] - tmp)
        if b[i] <= mon:
            ans += b[i] + tmp
            tmp = 0
        else:
            ans += a[i]
            tmp = b[i] - mon
    if tmp <= a[i + 1]:
        ans += tmp
    else:
        ans += a[i + 1]
    print(ans)


if __name__ == "__main__":
    main()

+    tmp = 0 -        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 +        mon = max(0, a[i] - tmp) +        if b[i] <= mon: +            ans += b[i] + tmp +            tmp = 0 +        else: +            ans += a[i] +            tmp = b[i] - mon +    if tmp <= a[i + 1]: +        ans += tmp +    else: +        ans += a[i + 1]