import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int N = Integer.parseInt(in.next());
            int A[] = new int[N + 1];
            int B[] = new int[N];
            for (int i = 0; i < N + 1; i++) {
                A[i] = Integer.parseInt(in.next());
            }
            for (int i = 0; i < N; i++) {
                B[i] = Integer.parseInt(in.next());
            }
            long ans = 0;
            for (int i = 0; i < N; i++) {
                int tmp = Math.min(B[i], A[i]);
                ans += tmp;
                tmp = Math.min(B[i] - tmp, A[i + 1]);
                A[i + 1] -= tmp;
                ans += tmp;
            }

            // 出力
            out.println(ans);

        }

    }
}
 import java.io.OutputStream; OutputStream java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int N = Integer.parseInt(in.next());
            int A[] = new int[N + 1];
            int B[] = new int[N];
            for (int i = 0; i < N + 1; i++) {
                A[i] = Integer.parseInt(in.next());
            }
            for (int i = 0; i < N; i++) {
                B[i] = Integer.parseInt(in.next());
            }
            long ans = 0;
            for (int i = 0; i < N; i++) {
                int tmp = Math.min(B[i], A[i]);
                ans += tmp;
                tmp = Math.min(B[i] - tmp, A[i + 1]);
                A[i + 1] -= tmp;
                ans += tmp;
            }

            // 出力
            out.println(ans);

        }

    }
} Main public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    } main {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    } InputStream inputStream = System.in; inputStream System.in System System.in OutputStream outputStream = System.out; outputStream System.out System System.out Scanner in = new Scanner(inputStream); in new Scanner(inputStream) PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) C solver = new C(); solver new C() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int N = Integer.parseInt(in.next());
            int A[] = new int[N + 1];
            int B[] = new int[N];
            for (int i = 0; i < N + 1; i++) {
                A[i] = Integer.parseInt(in.next());
            }
            for (int i = 0; i < N; i++) {
                B[i] = Integer.parseInt(in.next());
            }
            long ans = 0;
            for (int i = 0; i < N; i++) {
                int tmp = Math.min(B[i], A[i]);
                ans += tmp;
                tmp = Math.min(B[i] - tmp, A[i + 1]);
                A[i + 1] -= tmp;
                ans += tmp;
            }

            // 出力
            out.println(ans);

        }

    } C public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int N = Integer.parseInt(in.next());
            int A[] = new int[N + 1];
            int B[] = new int[N];
            for (int i = 0; i < N + 1; i++) {
                A[i] = Integer.parseInt(in.next());
            }
            for (int i = 0; i < N; i++) {
                B[i] = Integer.parseInt(in.next());
            }
            long ans = 0;
            for (int i = 0; i < N; i++) {
                int tmp = Math.min(B[i], A[i]);
                ans += tmp;
                tmp = Math.min(B[i] - tmp, A[i + 1]);
                A[i + 1] -= tmp;
                ans += tmp;
            }

            // 出力
            out.println(ans);

        } solve {
            // 入力
            int N = Integer.parseInt(in.next());
            int A[] = new int[N + 1];
            int B[] = new int[N];
            for (int i = 0; i < N + 1; i++) {
                A[i] = Integer.parseInt(in.next());
            }
            for (int i = 0; i < N; i++) {
                B[i] = Integer.parseInt(in.next());
            }
            long ans = 0;
            for (int i = 0; i < N; i++) {
                int tmp = Math.min(B[i], A[i]);
                ans += tmp;
                tmp = Math.min(B[i] - tmp, A[i + 1]);
                A[i + 1] -= tmp;
                ans += tmp;
            }

            // 出力
            out.println(ans);

        } int N = Integer.parseInt(in.next()); N Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in int A[] = new int[N + 1]; A new int[N + 1] N + 1 N 1 int B[] = new int[N]; B new int[N] N for (int i = 0; i < N + 1; i++) {
                A[i] = Integer.parseInt(in.next());
            } int i = 0; int i = 0; i 0 i < N + 1 i N + 1 N 1 i++ i++ i {
                A[i] = Integer.parseInt(in.next());
            } {
                A[i] = Integer.parseInt(in.next());
            } A[i] = Integer.parseInt(in.next()) A[i] A i Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in for (int i = 0; i < N; i++) {
                B[i] = Integer.parseInt(in.next());
            } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
                B[i] = Integer.parseInt(in.next());
            } {
                B[i] = Integer.parseInt(in.next());
            } B[i] = Integer.parseInt(in.next()) B[i] B i Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in long ans = 0; ans 0 for (int i = 0; i < N; i++) {
                int tmp = Math.min(B[i], A[i]);
                ans += tmp;
                tmp = Math.min(B[i] - tmp, A[i + 1]);
                A[i + 1] -= tmp;
                ans += tmp;
            } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
                int tmp = Math.min(B[i], A[i]);
                ans += tmp;
                tmp = Math.min(B[i] - tmp, A[i + 1]);
                A[i + 1] -= tmp;
                ans += tmp;
            } {
                int tmp = Math.min(B[i], A[i]);
                ans += tmp;
                tmp = Math.min(B[i] - tmp, A[i + 1]);
                A[i + 1] -= tmp;
                ans += tmp;
            } int tmp = Math.min(B[i], A[i]); tmp Math.min(B[i], A[i]) Math.min Math B[i] B i A[i] A i ans += tmp ans tmp tmp = Math.min(B[i] - tmp, A[i + 1]) tmp Math.min(B[i] - tmp, A[i + 1]) Math.min Math B[i] - tmp B[i] B i tmp A[i + 1] A i + 1 i 1 A[i + 1] -= tmp A[i + 1] A i + 1 i 1 tmp ans += tmp ans tmp out.println(ans) out.println out ans int testNumber testNumber Scanner in in PrintWriter out out public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int N = Integer.parseInt(in.next());
            int A[] = new int[N + 1];
            int B[] = new int[N];
            for (int i = 0; i < N + 1; i++) {
                A[i] = Integer.parseInt(in.next());
            }
            for (int i = 0; i < N; i++) {
                B[i] = Integer.parseInt(in.next());
            }
            long ans = 0;
            for (int i = 0; i < N; i++) {
                int tmp = Math.min(B[i], A[i]);
                ans += tmp;
                tmp = Math.min(B[i] - tmp, A[i + 1]);
                A[i + 1] -= tmp;
                ans += tmp;
            }

            // 出力
            out.println(ans);

        }

    }
} public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int N = Integer.parseInt(in.next());
            int A[] = new int[N + 1];
            int B[] = new int[N];
            for (int i = 0; i < N + 1; i++) {
                A[i] = Integer.parseInt(in.next());
            }
            for (int i = 0; i < N; i++) {
                B[i] = Integer.parseInt(in.next());
            }
            long ans = 0;
            for (int i = 0; i < N; i++) {
                int tmp = Math.min(B[i], A[i]);
                ans += tmp;
                tmp = Math.min(B[i] - tmp, A[i + 1]);
                A[i + 1] -= tmp;
                ans += tmp;
            }

            // 出力
            out.println(ans);

        }

    }
} Main
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int N = Integer.parseInt(in.next());
            int A[] = new int[N + 1];
            int B[] = new int[N];
            for (int i = 0; i < N + 1; i++) {
                A[i] = Integer.parseInt(in.next());
            }
            for (int i = 0; i < N; i++) {
                B[i] = Integer.parseInt(in.next());
            }
            long ans = 0;
            for (int i = 0; i < N; i++) {
                int tmp = Math.min(B[i], A[i]);
                ans += tmp;
                tmp = Math.min(B[i] - tmp, A[i + 1]);
                A[i + 1] -= tmp;
                ans += tmp;
            }

            // 出力
            out.println(ans);

        }

    }
}

