N = int(eval(input()))

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

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



ans = 0

for i in range(N):

    p = min(A[i], B[i])

    ans += p

    B[i] -= p

    p = min(A[i+1],B[i])

    ans += p

    A[i+1] -= p

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

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

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



ans = 0

for i,b in enumerate(B):

    x = min(A[i], b)

    ans += x

    b -= x

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

    ans += y

    A[i+1] -= y

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

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

-for i in range(N): -    p = min(A[i], B[i]) -    ans += p -    B[i] -= p -    p = min(A[i + 1], B[i]) -    ans += p -    A[i + 1] -= p +for i, b in enumerate(B): +    x = min(A[i], b) +    ans += x +    b -= x +    y = min(A[i + 1], b) +    ans += y +    A[i + 1] -= y