import sys

import os





def main():

    if os.getenv("LOCAL"):

        sys.stdin = open("input.txt", "r")



    N = int(sys.stdin.readline().rstrip())

    city = list(map(int, sys.stdin.readline().split()))

    brave = list(map(int, sys.stdin.readline().split()))



    init = sum(city)

    for n in range(N):

        bef = city[n]

        city[n] -= min(city[n], brave[n])

        city[n+1] -= min(city[n+1], brave[n]-min(bef, brave[n]))



    print((init-sum(city)))





if __name__ == '__main__':

    main()

import sys



sys.setrecursionlimit(10000000)

import os

import math

import bisect

import collections

import itertools

import heapq

import re

import queue



# import fractions



ii = lambda: int(sys.stdin.buffer.readline().rstrip())

il = lambda: list(map(int, sys.stdin.buffer.readline().split()))

fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))

iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]



iss = lambda: sys.stdin.buffer.readline().decode().rstrip()

sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))

isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]



lcm = lambda x, y: (x * y) // math.gcd(x, y)

# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)



MOD = 10 ** 9 + 7

MAX = float('inf')





def main():

    if os.getenv("LOCAL"):

        sys.stdin = open("input.txt", "r")



    N = ii()

    A = il()

    B = il()



    ret = 0

    for n in range(N):

        if B[n] >= A[n]+A[n+1]:

            ret += A[n] + A[n+1]

            A[n+1] = 0

        elif B[n] >= A[n]:

            ret += B[n]

            A[n+1] -= B[n] - A[n]

        else:

            ret += B[n]



    print(ret)





if __name__ == '__main__':

    main()

import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")
    N = int(sys.stdin.readline().rstrip())
    city = list(map(int, sys.stdin.readline().split()))
    brave = list(map(int, sys.stdin.readline().split()))
    init = sum(city)
    for n in range(N):
        bef = city[n]
        city[n] -= min(city[n], brave[n])
        city[n + 1] -= min(city[n + 1], brave[n] - min(bef, brave[n]))
    print((init - sum(city)))


if __name__ == "__main__":
    main()

import sys

sys.setrecursionlimit(10000000)
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue

# import fractions
ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]
iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]
lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)
MOD = 10**9 + 7
MAX = float("inf")


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")
    N = ii()
    A = il()
    B = il()
    ret = 0
    for n in range(N):
        if B[n] >= A[n] + A[n + 1]:
            ret += A[n] + A[n + 1]
            A[n + 1] = 0
        elif B[n] >= A[n]:
            ret += B[n]
            A[n + 1] -= B[n] - A[n]
        else:
            ret += B[n]
    print(ret)


if __name__ == "__main__":
    main()

+ +sys.setrecursionlimit(10000000) +import math +import bisect +import collections +import itertools +import heapq +import re +import queue + +# import fractions +ii = lambda: int(sys.stdin.buffer.readline().rstrip()) +il = lambda: list(map(int, sys.stdin.buffer.readline().split())) +fl = lambda: list(map(float, sys.stdin.buffer.readline().split())) +iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)] +iss = lambda: sys.stdin.buffer.readline().decode().rstrip() +sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split())) +isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)] +lcm = lambda x, y: (x * y) // math.gcd(x, y) +# lcm = lambda x, y: (x * y) // fractions.gcd(x, y) +MOD = 10**9 + 7 +MAX = float("inf") -    N = int(sys.stdin.readline().rstrip()) -    city = list(map(int, sys.stdin.readline().split())) -    brave = list(map(int, sys.stdin.readline().split())) -    init = sum(city) +    N = ii() +    A = il() +    B = il() +    ret = 0 -        bef = city[n] -        city[n] -= min(city[n], brave[n]) -        city[n + 1] -= min(city[n + 1], brave[n] - min(bef, brave[n])) -    print((init - sum(city))) +        if B[n] >= A[n] + A[n + 1]: +            ret += A[n] + A[n + 1] +            A[n + 1] = 0 +        elif B[n] >= A[n]: +            ret += B[n] +            A[n + 1] -= B[n] - A[n] +        else: +            ret += B[n] +    print(ret)