N=int(eval(input()))

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

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

x=0

for i in range(N):

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

    x+=A[i]+A[i+1]

    A[i+1]=0

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

    x+=B[i]

  elif A[i]<B[i]:

    x+=B[i]

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

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

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

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

count=0

for i in range(N):

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

    count+=A[i]+A[i+1]

    A[i+1]=0

  elif A[i]<=B[i]:

    count+=B[i]

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

  else:

    count+=B[i]

print(count)

              

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

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

-x = 0 +count = 0 -        x += A[i] + A[i + 1] +        count += A[i] + A[i + 1] -    elif A[i] >= B[i]: -        x += B[i] -    elif A[i] < B[i]: -        x += B[i] +    elif A[i] <= B[i]: +        count += B[i] -print(x) +    else: +        count += B[i] +print(count)