n = int(eval(input()))

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

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

c = 0

for i in range(n):

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

    c += b[i]

  else:

    d = b[i] -a[i]

    if a[i+1] <= d:

      c += a[i] + a[i+1]

      a[i+1] = 0

    else:

      a[i+1] -= d

      c += b[i]

print(c)
def main():

  n = int(eval(input()))

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

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

  c = 0

  for i in range(n):

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

      c += b[i]

    else:

      d = b[i] -a[i]

      if a[i+1] <= d:

        c += a[i] + a[i+1]

        a[i+1] = 0

      else:

        a[i+1] -= d

        c += b[i]

  print(c)



if __name__ == '__main__':

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

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


if __name__ == "__main__":
    main()

-n = int(eval(input())) -a = list(map(int, input().split())) -b = list(map(int, input().split())) -c = 0 -for i in range(n): -    if a[i] >= b[i]: -        c += b[i] -    else: -        d = b[i] - a[i] -        if a[i + 1] <= d: -            c += a[i] + a[i + 1] -            a[i + 1] = 0 +def main(): +    n = int(eval(input())) +    a = list(map(int, input().split())) +    b = list(map(int, input().split())) +    c = 0 +    for i in range(n): +        if a[i] >= b[i]: +            c += b[i] -            a[i + 1] -= d -            c += b[i] -print(c) +            d = b[i] - a[i] +            if a[i + 1] <= d: +                c += a[i] + a[i + 1] +                a[i + 1] = 0 +            else: +                a[i + 1] -= d +                c += b[i] +    print(c) + + +if __name__ == "__main__": +    main()