

import numpy as np

N = int(eval(input()))



A_ls = np.array(list(map(int,input().split(" "))))

B_ls = np.array(list(map(int,input().split(" "))))



S = 0



for i,b in enumerate(B_ls):

    if b > A_ls[i]:

        b -= A_ls[i]

        S += A_ls[i]

        if A_ls[i+1] >= b:

            A_ls[i+1] -=b

            S+=b

        else:

            S+=A_ls[i+1]

            A_ls[i+1] = 0 

    else:

        S += b



print(S)



N = int(eval(input()))



A_ls = list(map(int,input().split(" ")))

B_ls = list(map(int,input().split(" ")))



S = 0



for i,b in enumerate(B_ls):

    if b > A_ls[i]:

        b -= A_ls[i]

        S += A_ls[i]

        if A_ls[i+1] >= b:

            A_ls[i+1] -=b

            S+=b

        else:

            S+=A_ls[i+1]

            A_ls[i+1] = 0 

    else:

        S += b



print(S)

import numpy as np

N = int(eval(input()))
A_ls = np.array(list(map(int, input().split(" "))))
B_ls = np.array(list(map(int, input().split(" "))))
S = 0
for i, b in enumerate(B_ls):
    if b > A_ls[i]:
        b -= A_ls[i]
        S += A_ls[i]
        if A_ls[i + 1] >= b:
            A_ls[i + 1] -= b
            S += b
        else:
            S += A_ls[i + 1]
            A_ls[i + 1] = 0
    else:
        S += b
print(S)

N = int(eval(input()))
A_ls = list(map(int, input().split(" ")))
B_ls = list(map(int, input().split(" ")))
S = 0
for i, b in enumerate(B_ls):
    if b > A_ls[i]:
        b -= A_ls[i]
        S += A_ls[i]
        if A_ls[i + 1] >= b:
            A_ls[i + 1] -= b
            S += b
        else:
            S += A_ls[i + 1]
            A_ls[i + 1] = 0
    else:
        S += b
print(S)

-import numpy as np - -A_ls = np.array(list(map(int, input().split(" ")))) -B_ls = np.array(list(map(int, input().split(" ")))) +A_ls = list(map(int, input().split(" "))) +B_ls = list(map(int, input().split(" ")))