import sys



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



N = ir()

A = lr()

B = lr()

answer = 0

for i in range(N):

    a, b = A[i], B[i]

    answer += min(a, b)

    if a < b:

        remain = b - a

        add = min(A[i+1], remain)

        answer += add

        A[i+1] -= add



print(answer)

# coding: utf-8

import sys



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



N = ir()

A = lr()

B = lr()

remain = 0

answer = 0

for i in range(N):

    attack = min(A[i], remain)

    answer += attack

    A[i] -= attack

    if A[i] > 0:

        attack = min(A[i], B[i])

        answer += attack

        B[i] -= attack

    remain = B[i]



answer += min(A[N], remain)

print(answer)

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N = ir()
A = lr()
B = lr()
answer = 0
for i in range(N):
    a, b = A[i], B[i]
    answer += min(a, b)
    if a < b:
        remain = b - a
        add = min(A[i + 1], remain)
        answer += add
        A[i + 1] -= add
print(answer)

# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N = ir()
A = lr()
B = lr()
remain = 0
answer = 0
for i in range(N):
    attack = min(A[i], remain)
    answer += attack
    A[i] -= attack
    if A[i] > 0:
        attack = min(A[i], B[i])
        answer += attack
        B[i] -= attack
    remain = B[i]
answer += min(A[N], remain)
print(answer)

+# coding: utf-8 +remain = 0 -    a, b = A[i], B[i] -    answer += min(a, b) -    if a < b: -        remain = b - a -        add = min(A[i + 1], remain) -        answer += add -        A[i + 1] -= add +    attack = min(A[i], remain) +    answer += attack +    A[i] -= attack +    if A[i] > 0: +        attack = min(A[i], B[i]) +        answer += attack +        B[i] -= attack +    remain = B[i] +answer += min(A[N], remain)