n = int(eval(input()))

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

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



ans = 0

for i, bb in enumerate(b):

    use = min(a[i], b[i])

    ans += use

    a[i] -= use

    b[i] -= use



    if b[i] == 0:

        continue



    use = min(a[i + 1], b[i])

    ans += use

    a[i + 1] -= use



print(ans)

def main():

    N = int(eval(input()))

    *a, = list(map(int, input().split()))

    *b, = list(map(int, input().split()))

    b += [0]



    total_beaten = 0

    carry = 0

    for beat, number in zip(b, a):

        by_prev = min(number, carry)



        total_beaten += by_prev

        number -= by_prev



        by_curr = min(number, beat)

        total_beaten += by_curr



        carry = beat - by_curr



    print(total_beaten)





if __name__ == '__main__':

    main()

n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for i, bb in enumerate(b):
    use = min(a[i], b[i])
    ans += use
    a[i] -= use
    b[i] -= use
    if b[i] == 0:
        continue
    use = min(a[i + 1], b[i])
    ans += use
    a[i + 1] -= use
print(ans)

def main():
    N = int(eval(input()))
    (*a,) = list(map(int, input().split()))
    (*b,) = list(map(int, input().split()))
    b += [0]
    total_beaten = 0
    carry = 0
    for beat, number in zip(b, a):
        by_prev = min(number, carry)
        total_beaten += by_prev
        number -= by_prev
        by_curr = min(number, beat)
        total_beaten += by_curr
        carry = beat - by_curr
    print(total_beaten)


if __name__ == "__main__":
    main()

-n = int(eval(input())) -a = list(map(int, input().split())) -b = list(map(int, input().split())) -ans = 0 -for i, bb in enumerate(b): -    use = min(a[i], b[i]) -    ans += use -    a[i] -= use -    b[i] -= use -    if b[i] == 0: -        continue -    use = min(a[i + 1], b[i]) -    ans += use -    a[i + 1] -= use -print(ans) +def main(): +    N = int(eval(input())) +    (*a,) = list(map(int, input().split())) +    (*b,) = list(map(int, input().split())) +    b += [0] +    total_beaten = 0 +    carry = 0 +    for beat, number in zip(b, a): +        by_prev = min(number, carry) +        total_beaten += by_prev +        number -= by_prev +        by_curr = min(number, beat) +        total_beaten += by_curr +        carry = beat - by_curr +    print(total_beaten) + + +if __name__ == "__main__": +    main()