n = int(eval(input()))



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

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



d = 0

for i in range(n):

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

    d += b[i]



  else:

    d += a[i]

    b[i] = b[i] - a[i]

    

    if a[i+1] - b[i] >= 0:

      d += b[i]

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

      

    else:

      d += a[i+1]

      a[i+1] = 0

      

      

print(d)


def main():



  n = int(eval(input()))



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

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



  d = 0

  for i in range(n):

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

      d += b[i]



    else:

      d += a[i]

      b[i] = b[i] - a[i]



      if a[i+1] - b[i] >= 0:

        d += b[i]

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



      else:

        d += a[i+1]

        a[i+1] = 0





  print(d)





if __name__ == '__main__':

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

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


if __name__ == "__main__":
    main()

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