N=int(eval(input()))

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

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



counter=0

for i in range(N):

  if B[i]>=A[i]:

    counter+=A[i]

    B[i]-=A[i]

    

    if B[i]>=A[i+1]:

      counter+=A[i+1]

      A[i+1]=0

    else:

      counter+=B[i]

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

      

  else:

    counter+=B[i]

    

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

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

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



counter=0

for i in range(N):

  if A[i]>B[i]:

    counter+=B[i]

  else:

    counter+=A[i]

    B[i]-=A[i]

    if A[i+1]>B[i]:

      counter+=B[i]

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

    else:

      counter+=A[i+1]

      A[i+1]=0

      

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

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

-    if B[i] >= A[i]: +    if A[i] > B[i]: +        counter += B[i] +    else: -        if B[i] >= A[i + 1]: +        if A[i + 1] > B[i]: +            counter += B[i] +            A[i + 1] -= B[i] +        else: -        else: -            counter += B[i] -            A[i + 1] -= B[i] -    else: -        counter += B[i] -print(counter) +print((int(counter)))