# ABC135C - City Savers

# greedy algorithm

def main():

    n = int(eval(input()))

    A = list(map(int, input().rstrip().split()))

    B = tuple(map(int, input().rstrip().split()))

    ans = 0

    for i in range(n):

        cur1 = min(A[i], B[i])

        cur2 = min(A[i + 1], B[i] - cur1)

        A[i] -= cur1

        A[i + 1] -= cur2

        ans += cur1 + cur2

    print(ans)





if __name__ == "__main__":

    main()
# ABC135C - City Savers

# greedy algorithm

def main():

    n = int(eval(input()))

    A = tuple(map(int, input().rstrip().split()))

    B = tuple(map(int, input().rstrip().split()))

    ans, a1 = 0, A[0]

    for a2, b in zip(A[1:], B):

        cnt1 = min(a1, b)

        cnt2 = min(a2, b - cnt1)

        ans += cnt1 + cnt2

        a1 = a2 - cnt2  # a2 becomes a1 in next turn

    print(ans)





if __name__ == "__main__":

    main()
# ABC135C - City Savers
# greedy algorithm
def main():
    n = int(eval(input()))
    A = list(map(int, input().rstrip().split()))
    B = tuple(map(int, input().rstrip().split()))
    ans = 0
    for i in range(n):
        cur1 = min(A[i], B[i])
        cur2 = min(A[i + 1], B[i] - cur1)
        A[i] -= cur1
        A[i + 1] -= cur2
        ans += cur1 + cur2
    print(ans)


if __name__ == "__main__":
    main()

# ABC135C - City Savers
# greedy algorithm
def main():
    n = int(eval(input()))
    A = tuple(map(int, input().rstrip().split()))
    B = tuple(map(int, input().rstrip().split()))
    ans, a1 = 0, A[0]
    for a2, b in zip(A[1:], B):
        cnt1 = min(a1, b)
        cnt2 = min(a2, b - cnt1)
        ans += cnt1 + cnt2
        a1 = a2 - cnt2  # a2 becomes a1 in next turn
    print(ans)


if __name__ == "__main__":
    main()

-    A = list(map(int, input().rstrip().split())) +    A = tuple(map(int, input().rstrip().split())) -    ans = 0 -    for i in range(n): -        cur1 = min(A[i], B[i]) -        cur2 = min(A[i + 1], B[i] - cur1) -        A[i] -= cur1 -        A[i + 1] -= cur2 -        ans += cur1 + cur2 +    ans, a1 = 0, A[0] +    for a2, b in zip(A[1:], B): +        cnt1 = min(a1, b) +        cnt2 = min(a2, b - cnt1) +        ans += cnt1 + cnt2 +        a1 = a2 - cnt2  # a2 becomes a1 in next turn