n = int(eval(input()))

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

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

ans = 0

for i in range(n):

    if a[i] <= b[i]:

        ans += a[i]

        b[i] -= a[i]

        if a[i + 1] <= b[i]:

            ans += a[i + 1]

            a[i + 1] = 0

        else:

            ans += b[i]

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

    else:

        ans += b[i]

print(ans)
n = int(eval(input()))

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

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



ans = 0

now = a[0]

for i in range(n):

    ato_taoseru = b[i]

    if ato_taoseru <= now:

        ans += ato_taoseru

        now = a[i + 1]

    else:

        ans += now

        ato_taoseru -= now

        now = a[i + 1]

        if ato_taoseru <= now:

            ans += ato_taoseru

            now -= ato_taoseru

        else:

            ans += now

            now = 0



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

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

+now = a[0] -    if a[i] <= b[i]: -        ans += a[i] -        b[i] -= a[i] -        if a[i + 1] <= b[i]: -            ans += a[i + 1] -            a[i + 1] = 0 +    ato_taoseru = b[i] +    if ato_taoseru <= now: +        ans += ato_taoseru +        now = a[i + 1] +    else: +        ans += now +        ato_taoseru -= now +        now = a[i + 1] +        if ato_taoseru <= now: +            ans += ato_taoseru +            now -= ato_taoseru -            ans += b[i] -            a[i + 1] -= b[i] -    else: -        ans += b[i] +            ans += now +            now = 0