def LI():

  return [int(s) for s in input().split()]



N = int(eval(input()))



A_s = LI()

B_s = LI()



counter = 0



for i in range(N):

  if A_s[i] > B_s[i]:

    counter+=B_s[i]

  elif B_s[i] < A_s[i] + A_s[i+1]:

    counter+=B_s[i]

    A_s[i+1] = A_s[i+1] - (B_s[i]-A_s[i])

  else:

    counter+=A_s[i]+A_s[i+1]

    A_s[i+1] = 0

    

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

A = [int(s) for s in input().split()]

sum_A = sum(A)

B = [int(s) for s in input().split()]

for i in range(N):

    attack1 = A[i] - B[i]

    if attack1 < 0:

        attack2 = A[i + 1] + attack1

        A[i] = 0

        A[i + 1] = attack2 if attack2 >= 0 else 0

    else:

        A[i] = attack1



print((sum_A - sum(A)))

def LI():
    return [int(s) for s in input().split()]


N = int(eval(input()))
A_s = LI()
B_s = LI()
counter = 0
for i in range(N):
    if A_s[i] > B_s[i]:
        counter += B_s[i]
    elif B_s[i] < A_s[i] + A_s[i + 1]:
        counter += B_s[i]
        A_s[i + 1] = A_s[i + 1] - (B_s[i] - A_s[i])
    else:
        counter += A_s[i] + A_s[i + 1]
        A_s[i + 1] = 0
print(counter)

N = int(eval(input()))
A = [int(s) for s in input().split()]
sum_A = sum(A)
B = [int(s) for s in input().split()]
for i in range(N):
    attack1 = A[i] - B[i]
    if attack1 < 0:
        attack2 = A[i + 1] + attack1
        A[i] = 0
        A[i + 1] = attack2 if attack2 >= 0 else 0
    else:
        A[i] = attack1
print((sum_A - sum(A)))

-def LI(): -    return [int(s) for s in input().split()] - - -A_s = LI() -B_s = LI() -counter = 0 +A = [int(s) for s in input().split()] +sum_A = sum(A) +B = [int(s) for s in input().split()] -    if A_s[i] > B_s[i]: -        counter += B_s[i] -    elif B_s[i] < A_s[i] + A_s[i + 1]: -        counter += B_s[i] -        A_s[i + 1] = A_s[i + 1] - (B_s[i] - A_s[i]) +    attack1 = A[i] - B[i] +    if attack1 < 0: +        attack2 = A[i + 1] + attack1 +        A[i] = 0 +        A[i + 1] = attack2 if attack2 >= 0 else 0 -        counter += A_s[i] + A_s[i + 1] -        A_s[i + 1] = 0 -print(counter) +        A[i] = attack1 +print((sum_A - sum(A)))