import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(int n, int[] a, int[] b) {
    long ans = 0;
    long x = 0;
    for (int i = 0; i < n; i++) {
        ans += min(a[i], b[i]);
        int d = b[i] - a[i];
        if (d > 0) {
            ans += min(a[i+1], d);
            a[i+1] = max(0, a[i+1] - d);
        }
    }
    return ans;
}

void main() {
    int n; scan(n);
    auto a = readints;
    auto b = readints;
    writeln(calc(n, a, b));
}
