n=int(eval(input()))

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

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

count=0

for i in range(n):

  if b[i]-a[i]>0:

    count+=a[i]

    if a[i+1]>(b[i]-a[i]):

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

      count+=(b[i]-a[i])

    elif a[i+1]<=b[i]-a[i]:

      count+=a[i+1]

      a[i+1]=0

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

    count+=b[i]   

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

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

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

ans=0

for i in range(n):

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

    ans+=b[i]

  else:

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

      ans+=b[i]

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

      if a[i+1]<0:

        a[i+1]=0

    else:

      if b[i]>a[i]+a[i+1]:

        ans+=a[i]+a[i+1]

        a[i+1]=0

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

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

-count = 0 +ans = 0 -    if b[i] - a[i] > 0: -        count += a[i] -        if a[i + 1] > (b[i] - a[i]): +    if b[i] <= a[i]: +        ans += b[i] +    else: +        if b[i] <= a[i] + a[i + 1]: +            ans += b[i] -            count += b[i] - a[i] -        elif a[i + 1] <= b[i] - a[i]: -            count += a[i + 1] -            a[i + 1] = 0 -    elif b[i] <= a[i]: -        count += b[i] -print(count) +            if a[i + 1] < 0: +                a[i + 1] = 0 +        else: +            if b[i] > a[i] + a[i + 1]: +                ans += a[i] + a[i + 1] +                a[i + 1] = 0 +print(ans)