N=int(eval(input()))

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

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

count=0

for i in range(N):

    count+=min(A[i],B[i])

    if A[i]<B[i]:

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

            count+=A[i+1]

            A[i+1]=0

        else:

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

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

print(count)
N=int(eval(input()))

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

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

count=0

for i,b in enumerate(B):

    attack=min(b,A[i]+A[i+1])

    count+=attack

    A[i+1]-=max(0,attack-A[i])

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

N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
count = 0
for i, b in enumerate(B):
    attack = min(b, A[i] + A[i + 1])
    count += attack
    A[i + 1] -= max(0, attack - A[i])
print(count)

-for i in range(N): -    count += min(A[i], B[i]) -    if A[i] < B[i]: -        if A[i + 1] < B[i] - A[i]: -            count += A[i + 1] -            A[i + 1] = 0 -        else: -            count += B[i] - A[i] -            A[i + 1] -= B[i] - A[i] +for i, b in enumerate(B): +    attack = min(b, A[i] + A[i + 1]) +    count += attack +    A[i + 1] -= max(0, attack - A[i])