import std.algorithm;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.meta;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;

auto solve(long N, long[] A, long[] B){
    long ans;
    foreach (i; iota(N.to!uint).retro) {
        const a = min(A[i + 1], B[i]);
        A[i + 1] -= a;
        B[i] -= a;
        ans += a;

        const b = min(A[i], B[i]);
        A[i] -= b;
        B[i] -= b;
        ans += b;
    }
    return ans;
}

void main(){
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long[] A = new long[](cast(size_t) (N+1));
    foreach (i; 0 .. cast(size_t) (N+1)) {
        A[i] = input.front.to!long;
        input.popFront;
    }

    long[] B = new long[](cast(size_t) (N));
    foreach (i; 0 .. cast(size_t) (N)) {
        B[i] = input.front.to!long;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, A, B);
    else
        solve(N, A, B).writeln;
}
