import sys, heapq, bisect, math, fractions

from collections import deque



N = int(eval(input()))

A = list(map(int, sys.stdin.readline().rsplit()))

B = list(map(int, sys.stdin.readline().rsplit()))



res = 0

for i, b in enumerate(B):

    a = A[i]

    a1 = A[i + 1]

    if a >= b:

        res += b

    else:

        res += a

        if a1 >= b - a:

            A[i + 1] = a1 - (b - a)

            res += b - a

        else:

            A[i + 1] = 0

            res += a1



print(res)
import sys



N = int(eval(input()))

A = list(map(int, sys.stdin.readline().rsplit()))

B = list(map(int, sys.stdin.readline().rsplit()))



res = 0

for i, b in enumerate(B):

    a = A[i]

    a1 = A[i + 1]

    if a >= b:

        res += b

    else:

        res += a

        if a1 >= b - a:

            A[i + 1] = a1 - (b - a)

            res += b - a

        else:

            A[i + 1] = 0

            res += a1



print(res)
import sys, heapq, bisect, math, fractions
from collections import deque

N = int(eval(input()))
A = list(map(int, sys.stdin.readline().rsplit()))
B = list(map(int, sys.stdin.readline().rsplit()))
res = 0
for i, b in enumerate(B):
    a = A[i]
    a1 = A[i + 1]
    if a >= b:
        res += b
    else:
        res += a
        if a1 >= b - a:
            A[i + 1] = a1 - (b - a)
            res += b - a
        else:
            A[i + 1] = 0
            res += a1
print(res)

import sys

N = int(eval(input()))
A = list(map(int, sys.stdin.readline().rsplit()))
B = list(map(int, sys.stdin.readline().rsplit()))
res = 0
for i, b in enumerate(B):
    a = A[i]
    a1 = A[i + 1]
    if a >= b:
        res += b
    else:
        res += a
        if a1 >= b - a:
            A[i + 1] = a1 - (b - a)
            res += b - a
        else:
            A[i + 1] = 0
            res += a1
print(res)

-import sys, heapq, bisect, math, fractions -from collections import deque +import sys