import sys

def input(): return sys.stdin.readline().strip()



def resolve():

    n=int(eval(input()))

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

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

    cnt=0

    for i in range(n):

        if la[i]>=lb[i]:

            cnt+=lb[i]

            la[i]-=lb[i]

        else:

            cnt+=la[i]

            lb[i]-=la[i]

            cnt+=min(lb[i],la[i+1])

            la[i+1]-=min(lb[i],la[i+1])

    print(cnt)

resolve()
import sys

def input(): return sys.stdin.readline().strip()



def resolve():

    n=int(eval(input()))

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

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

    cnt=0

    for i in range(n):

        x=min(la[i],lb[i])

        cnt+=x

        lb[i]-=x

        la[i]-=x

        y=min(lb[i],la[i+1])

        cnt+=y

        la[i+1]-=y

    print(cnt)

resolve()

import sys


def input():
    return sys.stdin.readline().strip()


def resolve():
    n = int(eval(input()))
    la = list(map(int, input().split()))
    lb = list(map(int, input().split()))
    cnt = 0
    for i in range(n):
        if la[i] >= lb[i]:
            cnt += lb[i]
            la[i] -= lb[i]
        else:
            cnt += la[i]
            lb[i] -= la[i]
            cnt += min(lb[i], la[i + 1])
            la[i + 1] -= min(lb[i], la[i + 1])
    print(cnt)


resolve()

import sys


def input():
    return sys.stdin.readline().strip()


def resolve():
    n = int(eval(input()))
    la = list(map(int, input().split()))
    lb = list(map(int, input().split()))
    cnt = 0
    for i in range(n):
        x = min(la[i], lb[i])
        cnt += x
        lb[i] -= x
        la[i] -= x
        y = min(lb[i], la[i + 1])
        cnt += y
        la[i + 1] -= y
    print(cnt)


resolve()

-        if la[i] >= lb[i]: -            cnt += lb[i] -            la[i] -= lb[i] -        else: -            cnt += la[i] -            lb[i] -= la[i] -            cnt += min(lb[i], la[i + 1]) -            la[i + 1] -= min(lb[i], la[i + 1]) +        x = min(la[i], lb[i]) +        cnt += x +        lb[i] -= x +        la[i] -= x +        y = min(lb[i], la[i + 1]) +        cnt += y +        la[i + 1] -= y