R = lambda: list(map(int, input().split()))

eval(input())

a, b = list(R()), R()

r = 0

for i, u in enumerate(b):

    x = min(a[i], u)

    y = min(a[i + 1], u - x)

    a[i + 1] -= y

    r += x + y

print(r)

R = lambda: list(map(int, input().split()))

eval(input())

a, b = list(R()), R()

r = y = 0

for u, v, w in zip(b, a, a[1:]):

    x = min(v - y, u)

    y = min(w, u - x)

    r += x + y

print(r)

R = lambda: list(map(int, input().split()))
eval(input())
a, b = list(R()), R()
r = 0
for i, u in enumerate(b):
    x = min(a[i], u)
    y = min(a[i + 1], u - x)
    a[i + 1] -= y
    r += x + y
print(r)

R = lambda: list(map(int, input().split()))
eval(input())
a, b = list(R()), R()
r = y = 0
for u, v, w in zip(b, a, a[1:]):
    x = min(v - y, u)
    y = min(w, u - x)
    r += x + y
print(r)

-r = 0 -for i, u in enumerate(b): -    x = min(a[i], u) -    y = min(a[i + 1], u - x) -    a[i + 1] -= y +r = y = 0 +for u, v, w in zip(b, a, a[1:]): +    x = min(v - y, u) +    y = min(w, u - x)