n = int(eval(input()))

a = [int(x) for x in input().split()]

b = [int(x) for x in input().split()]



assist = 0

kill = 0



for i in range(n):

    if assist+b[i] < a[i]:

        kill += assist+b[i]

        assist = 0

    else:

        if assist <= a[i]:

            kill += a[i]

            assist += b[i] - a[i]

        else:

            kill += a[i]

            assist = b[i]



if assist == 0:

    print(kill)

elif assist < a[-1]:

    print((kill + assist))

else:

    print((kill + a[-1]))
n = int(eval(input()))

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

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



assist = 0

kill = 0



for i in range(n):

    if assist+b[i] < a[i]:

        kill += assist+b[i]

        assist = 0

    else:

        if assist <= a[i]:

            kill += a[i]

            assist += b[i] - a[i]

        else:

            kill += a[i]

            assist = b[i]



if assist == 0:

    print(kill)

elif assist < a[-1]:

    print((kill + assist))

else:

    print((kill + a[-1]))
n = int(eval(input()))
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
assist = 0
kill = 0
for i in range(n):
    if assist + b[i] < a[i]:
        kill += assist + b[i]
        assist = 0
    else:
        if assist <= a[i]:
            kill += a[i]
            assist += b[i] - a[i]
        else:
            kill += a[i]
            assist = b[i]
if assist == 0:
    print(kill)
elif assist < a[-1]:
    print((kill + assist))
else:
    print((kill + a[-1]))

n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
assist = 0
kill = 0
for i in range(n):
    if assist + b[i] < a[i]:
        kill += assist + b[i]
        assist = 0
    else:
        if assist <= a[i]:
            kill += a[i]
            assist += b[i] - a[i]
        else:
            kill += a[i]
            assist = b[i]
if assist == 0:
    print(kill)
elif assist < a[-1]:
    print((kill + assist))
else:
    print((kill + a[-1]))

-a = [int(x) for x in input().split()] -b = [int(x) for x in input().split()] +a = list(map(int, input().split())) +b = list(map(int, input().split()))