def main():

    N = int(eval(input()))

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

    *B, = list(map(int, input().split()))



    ans = 0

    for i, can_beat in enumerate(B):

        beat = min(A[i], can_beat)

        A[i] -= beat

        can_beat -= beat

        ans += beat



        beat = min(A[i + 1], can_beat)

        A[i + 1] -= beat

        ans += beat



    print(ans)





if __name__ == '__main__':

    main()

def main():

    N = int(eval(input()))

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

    *B, = list(map(int, input().split()))



    ans = 0

    for i in range(N):

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

        A[i] -= beaten

        B[i] -= beaten

        ans += beaten



        if B[i]:

            beaten = min(A[i + 1], B[i])

            A[i + 1] -= beaten

            B[i] -= beaten

            ans += beaten



    print(ans)





if __name__ == '__main__':

    main()

def main():
    N = int(eval(input()))
    (*A,) = list(map(int, input().split()))
    (*B,) = list(map(int, input().split()))
    ans = 0
    for i, can_beat in enumerate(B):
        beat = min(A[i], can_beat)
        A[i] -= beat
        can_beat -= beat
        ans += beat
        beat = min(A[i + 1], can_beat)
        A[i + 1] -= beat
        ans += beat
    print(ans)


if __name__ == "__main__":
    main()

def main():
    N = int(eval(input()))
    (*A,) = list(map(int, input().split()))
    (*B,) = list(map(int, input().split()))
    ans = 0
    for i in range(N):
        beaten = min(A[i], B[i])
        A[i] -= beaten
        B[i] -= beaten
        ans += beaten
        if B[i]:
            beaten = min(A[i + 1], B[i])
            A[i + 1] -= beaten
            B[i] -= beaten
            ans += beaten
    print(ans)


if __name__ == "__main__":
    main()

-    for i, can_beat in enumerate(B): -        beat = min(A[i], can_beat) -        A[i] -= beat -        can_beat -= beat -        ans += beat -        beat = min(A[i + 1], can_beat) -        A[i + 1] -= beat -        ans += beat +    for i in range(N): +        beaten = min(A[i], B[i]) +        A[i] -= beaten +        B[i] -= beaten +        ans += beaten +        if B[i]: +            beaten = min(A[i + 1], B[i]) +            A[i + 1] -= beaten +            B[i] -= beaten +            ans += beaten