import sys

import itertools



# import numpy as np



read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



N, *AB = list(map(int, read().split()))

A = AB[:N + 1]

B = AB[N + 1:]



ans = 0

cnt = 0

for i, j in zip(A, B):

    # print(f'A:{i} B:{j} cnt:{cnt}')

    ans += min(i, cnt)

    m = min(i-cnt, j)

    m=max(m,0)

    ans += m

    cnt = max(j - m, 0)

ans += min(A[-1], cnt)



print(ans)
import sys

import itertools



# import numpy as np



read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



N, *AB = list(map(int, read().split()))

A = AB[:N + 1]

B = AB[N + 1:]



B.append(0)

ans = 0

rest = 0

for i, j in zip(A, B):

    x = min(rest, i)

    ans += x

    i -= x

    if i < j:

        ans += i

        rest = j - i

    else:

        ans += j

        rest = 0

print(ans)

import sys
import itertools

# import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, *AB = list(map(int, read().split()))
A = AB[: N + 1]
B = AB[N + 1 :]
ans = 0
cnt = 0
for i, j in zip(A, B):
    # print(f'A:{i} B:{j} cnt:{cnt}')
    ans += min(i, cnt)
    m = min(i - cnt, j)
    m = max(m, 0)
    ans += m
    cnt = max(j - m, 0)
ans += min(A[-1], cnt)
print(ans)

import sys
import itertools

# import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, *AB = list(map(int, read().split()))
A = AB[: N + 1]
B = AB[N + 1 :]
B.append(0)
ans = 0
rest = 0
for i, j in zip(A, B):
    x = min(rest, i)
    ans += x
    i -= x
    if i < j:
        ans += i
        rest = j - i
    else:
        ans += j
        rest = 0
print(ans)

+B.append(0) -cnt = 0 +rest = 0 -    # print(f'A:{i} B:{j} cnt:{cnt}') -    ans += min(i, cnt) -    m = min(i - cnt, j) -    m = max(m, 0) -    ans += m -    cnt = max(j - m, 0) -ans += min(A[-1], cnt) +    x = min(rest, i) +    ans += x +    i -= x +    if i < j: +        ans += i +        rest = j - i +    else: +        ans += j +        rest = 0