N = int(eval(input()))

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

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

cnt = 0



for i in range(N):

    if heros[i] <= mosters[i]:

        cnt += heros[i]

    else:

        cnt += mosters[i]

        if (heros[i] - mosters[i]) >= mosters[i+1]:

            cnt += mosters[i+1]

            mosters[i+1] = 0

        else:

            cnt += heros[i] - mosters[i]

            mosters[i+1] -= (heros[i] - mosters[i])



print(cnt)
def main():

    N = int(eval(input()))

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

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



    ans = 0

    for i in range(N):

        b = B[i]

        if A[i] >= b:

            ans += b

        else:

            b -= A[i]

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

            A[i+1] = max(A[i+1] - b, 0)



    print(ans)





if __name__ == "__main__":

    main()
N = int(eval(input()))
mosters = list(map(int, input().split()))
heros = list(map(int, input().split()))
cnt = 0
for i in range(N):
    if heros[i] <= mosters[i]:
        cnt += heros[i]
    else:
        cnt += mosters[i]
        if (heros[i] - mosters[i]) >= mosters[i + 1]:
            cnt += mosters[i + 1]
            mosters[i + 1] = 0
        else:
            cnt += heros[i] - mosters[i]
            mosters[i + 1] -= heros[i] - mosters[i]
print(cnt)

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


if __name__ == "__main__":
    main()

-N = int(eval(input())) -mosters = list(map(int, input().split())) -heros = list(map(int, input().split())) -cnt = 0 -for i in range(N): -    if heros[i] <= mosters[i]: -        cnt += heros[i] -    else: -        cnt += mosters[i] -        if (heros[i] - mosters[i]) >= mosters[i + 1]: -            cnt += mosters[i + 1] -            mosters[i + 1] = 0 +def main(): +    N = int(eval(input())) +    A = list(map(int, input().split())) +    B = list(map(int, input().split())) +    ans = 0 +    for i in range(N): +        b = B[i] +        if A[i] >= b: +            ans += b -            cnt += heros[i] - mosters[i] -            mosters[i + 1] -= heros[i] - mosters[i] -print(cnt) +            b -= A[i] +            ans += A[i] + min(b, A[i + 1]) +            A[i + 1] = max(A[i + 1] - b, 0) +    print(ans) + + +if __name__ == "__main__": +    main()