import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    public static final PrintStream out = System.out;
    public static final PrintStream err = System.err;

    public static void main(String[] args) {
        int N = in.nextInt();
        int[] A = new int[N + 1];
        int[] B = new int[N];
        for (int i = 0; i < N + 1; i++) {
            A[i] = in.nextInt();
        }
        for (int i = 0; i < N; i++) {
            B[i] = in.nextInt();
        }

        long r = 0, d = 0;
        for (int i = 0; i < N; i++) {
            int a = A[i];
            int b = B[i];

            d = Math.min(a, d);

            r += d;
            a -= d;

            r += Math.min(a, b);
            d = Math.max(0, b - a);
        }
        r += Math.min(A[N], d);

        out.println(r);
    }
} import java.io.*; io.* java import java.util.*; util.* java import java.util.stream.*; stream.* java.util public class Main {
    public static final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    public static final PrintStream out = System.out;
    public static final PrintStream err = System.err;

    public static void main(String[] args) {
        int N = in.nextInt();
        int[] A = new int[N + 1];
        int[] B = new int[N];
        for (int i = 0; i < N + 1; i++) {
            A[i] = in.nextInt();
        }
        for (int i = 0; i < N; i++) {
            B[i] = in.nextInt();
        }

        long r = 0, d = 0;
        for (int i = 0; i < N; i++) {
            int a = A[i];
            int b = B[i];

            d = Math.min(a, d);

            r += d;
            a -= d;

            r += Math.min(a, b);
            d = Math.max(0, b - a);
        }
        r += Math.min(A[N], d);

        out.println(r);
    }
} Main public static final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in))); in new Scanner(new BufferedReader(new InputStreamReader(System.in))) public static final PrintStream out = System.out; out System.out System System.out public static final PrintStream err = System.err; err System.err System System.err public static void main(String[] args) {
        int N = in.nextInt();
        int[] A = new int[N + 1];
        int[] B = new int[N];
        for (int i = 0; i < N + 1; i++) {
            A[i] = in.nextInt();
        }
        for (int i = 0; i < N; i++) {
            B[i] = in.nextInt();
        }

        long r = 0, d = 0;
        for (int i = 0; i < N; i++) {
            int a = A[i];
            int b = B[i];

            d = Math.min(a, d);

            r += d;
            a -= d;

            r += Math.min(a, b);
            d = Math.max(0, b - a);
        }
        r += Math.min(A[N], d);

        out.println(r);
    } main {
        int N = in.nextInt();
        int[] A = new int[N + 1];
        int[] B = new int[N];
        for (int i = 0; i < N + 1; i++) {
            A[i] = in.nextInt();
        }
        for (int i = 0; i < N; i++) {
            B[i] = in.nextInt();
        }

        long r = 0, d = 0;
        for (int i = 0; i < N; i++) {
            int a = A[i];
            int b = B[i];

            d = Math.min(a, d);

            r += d;
            a -= d;

            r += Math.min(a, b);
            d = Math.max(0, b - a);
        }
        r += Math.min(A[N], d);

        out.println(r);
    } int N = in.nextInt(); N in.nextInt() in.nextInt 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] = in.nextInt();
        } int i = 0; int i = 0; i 0 i < N + 1 i N + 1 N 1 i++ i++ i {
            A[i] = in.nextInt();
        } {
            A[i] = in.nextInt();
        } A[i] = in.nextInt() A[i] A i in.nextInt() in.nextInt in for (int i = 0; i < N; i++) {
            B[i] = in.nextInt();
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            B[i] = in.nextInt();
        } {
            B[i] = in.nextInt();
        } B[i] = in.nextInt() B[i] B i in.nextInt() in.nextInt in long r = 0 r 0 d = 0; d 0 for (int i = 0; i < N; i++) {
            int a = A[i];
            int b = B[i];

            d = Math.min(a, d);

            r += d;
            a -= d;

            r += Math.min(a, b);
            d = Math.max(0, b - a);
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            int a = A[i];
            int b = B[i];

            d = Math.min(a, d);

            r += d;
            a -= d;

            r += Math.min(a, b);
            d = Math.max(0, b - a);
        } {
            int a = A[i];
            int b = B[i];

            d = Math.min(a, d);

            r += d;
            a -= d;

            r += Math.min(a, b);
            d = Math.max(0, b - a);
        } int a = A[i]; a A[i] A i int b = B[i]; b B[i] B i d = Math.min(a, d) d Math.min(a, d) Math.min Math a d r += d r d a -= d a d r += Math.min(a, b) r Math.min(a, b) Math.min Math a b d = Math.max(0, b - a) d Math.max(0, b - a) Math.max Math 0 b - a b a r += Math.min(A[N], d) r Math.min(A[N], d) Math.min Math A[N] A N d out.println(r) out.println out r String[] args args public class Main {
    public static final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    public static final PrintStream out = System.out;
    public static final PrintStream err = System.err;

    public static void main(String[] args) {
        int N = in.nextInt();
        int[] A = new int[N + 1];
        int[] B = new int[N];
        for (int i = 0; i < N + 1; i++) {
            A[i] = in.nextInt();
        }
        for (int i = 0; i < N; i++) {
            B[i] = in.nextInt();
        }

        long r = 0, d = 0;
        for (int i = 0; i < N; i++) {
            int a = A[i];
            int b = B[i];

            d = Math.min(a, d);

            r += d;
            a -= d;

            r += Math.min(a, b);
            d = Math.max(0, b - a);
        }
        r += Math.min(A[N], d);

        out.println(r);
    }
} public class Main {
    public static final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    public static final PrintStream out = System.out;
    public static final PrintStream err = System.err;

    public static void main(String[] args) {
        int N = in.nextInt();
        int[] A = new int[N + 1];
        int[] B = new int[N];
        for (int i = 0; i < N + 1; i++) {
            A[i] = in.nextInt();
        }
        for (int i = 0; i < N; i++) {
            B[i] = in.nextInt();
        }

        long r = 0, d = 0;
        for (int i = 0; i < N; i++) {
            int a = A[i];
            int b = B[i];

            d = Math.min(a, d);

            r += d;
            a -= d;

            r += Math.min(a, b);
            d = Math.max(0, b - a);
        }
        r += Math.min(A[N], d);

        out.println(r);
    }
} Main
import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    public static final PrintStream out = System.out;
    public static final PrintStream err = System.err;

    public static void main(String[] args) {
        int N = in.nextInt();
        int[] A = new int[N + 1];
        int[] B = new int[N];
        for (int i = 0; i < N + 1; i++) {
            A[i] = in.nextInt();
        }
        for (int i = 0; i < N; i++) {
            B[i] = in.nextInt();
        }

        long r = 0, d = 0;
        for (int i = 0; i < N; i++) {
            int a = A[i];
            int b = B[i];

            d = Math.min(a, d);

            r += d;
            a -= d;

            r += Math.min(a, b);
            d = Math.max(0, b - a);
        }
        r += Math.min(A[N], d);

        out.println(r);
    }
}
