import java.util.Scanner;

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

            long count = 0;
            for (int i = 0; i < N; i++) {
                int min = Math.min(A[i], B[i]);
                A[i] -= min;
                B[i] -= min;
                count += min;

                int min2 = Math.min(A[i + 1], B[i]);
                A[i + 1] -= min2;
                B[i] -= min2;
                count += min2;
            }
            System.out.println(count);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] A = new int[N + 1];
            for (int i = 0; i < N + 1; i++) {
                A[i] = in.nextInt();
            }
            int[] B = new int[N];
            for (int i = 0; i < N; i++) {
                B[i] = in.nextInt();
            }

            long count = 0;
            for (int i = 0; i < N; i++) {
                int min = Math.min(A[i], B[i]);
                A[i] -= min;
                B[i] -= min;
                count += min;

                int min2 = Math.min(A[i + 1], B[i]);
                A[i + 1] -= min2;
                B[i] -= min2;
                count += min2;
            }
            System.out.println(count);
        }
    }
} Main public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] A = new int[N + 1];
            for (int i = 0; i < N + 1; i++) {
                A[i] = in.nextInt();
            }
            int[] B = new int[N];
            for (int i = 0; i < N; i++) {
                B[i] = in.nextInt();
            }

            long count = 0;
            for (int i = 0; i < N; i++) {
                int min = Math.min(A[i], B[i]);
                A[i] -= min;
                B[i] -= min;
                count += min;

                int min2 = Math.min(A[i + 1], B[i]);
                A[i + 1] -= min2;
                B[i] -= min2;
                count += min2;
            }
            System.out.println(count);
        }
    } main {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] A = new int[N + 1];
            for (int i = 0; i < N + 1; i++) {
                A[i] = in.nextInt();
            }
            int[] B = new int[N];
            for (int i = 0; i < N; i++) {
                B[i] = in.nextInt();
            }

            long count = 0;
            for (int i = 0; i < N; i++) {
                int min = Math.min(A[i], B[i]);
                A[i] -= min;
                B[i] -= min;
                count += min;

                int min2 = Math.min(A[i + 1], B[i]);
                A[i + 1] -= min2;
                B[i] -= min2;
                count += min2;
            }
            System.out.println(count);
        }
    } try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] A = new int[N + 1];
            for (int i = 0; i < N + 1; i++) {
                A[i] = in.nextInt();
            }
            int[] B = new int[N];
            for (int i = 0; i < N; i++) {
                B[i] = in.nextInt();
            }

            long count = 0;
            for (int i = 0; i < N; i++) {
                int min = Math.min(A[i], B[i]);
                A[i] -= min;
                B[i] -= min;
                count += min;

                int min2 = Math.min(A[i + 1], B[i]);
                A[i + 1] -= min2;
                B[i] -= min2;
                count += min2;
            }
            System.out.println(count);
        } {
            int N = in.nextInt();
            int[] A = new int[N + 1];
            for (int i = 0; i < N + 1; i++) {
                A[i] = in.nextInt();
            }
            int[] B = new int[N];
            for (int i = 0; i < N; i++) {
                B[i] = in.nextInt();
            }

            long count = 0;
            for (int i = 0; i < N; i++) {
                int min = Math.min(A[i], B[i]);
                A[i] -= min;
                B[i] -= min;
                count += min;

                int min2 = Math.min(A[i + 1], B[i]);
                A[i + 1] -= min2;
                B[i] -= min2;
                count += min2;
            }
            System.out.println(count);
        } Scanner in = new Scanner(System.in) Scanner in = new Scanner(System.in) new Scanner(System.in) 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 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 int[] B = new int[N]; B new int[N] N 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 count = 0; count 0 for (int i = 0; i < N; i++) {
                int min = Math.min(A[i], B[i]);
                A[i] -= min;
                B[i] -= min;
                count += min;

                int min2 = Math.min(A[i + 1], B[i]);
                A[i + 1] -= min2;
                B[i] -= min2;
                count += min2;
            } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
                int min = Math.min(A[i], B[i]);
                A[i] -= min;
                B[i] -= min;
                count += min;

                int min2 = Math.min(A[i + 1], B[i]);
                A[i + 1] -= min2;
                B[i] -= min2;
                count += min2;
            } {
                int min = Math.min(A[i], B[i]);
                A[i] -= min;
                B[i] -= min;
                count += min;

                int min2 = Math.min(A[i + 1], B[i]);
                A[i + 1] -= min2;
                B[i] -= min2;
                count += min2;
            } int min = Math.min(A[i], B[i]); min Math.min(A[i], B[i]) Math.min Math A[i] A i B[i] B i A[i] -= min A[i] A i min B[i] -= min B[i] B i min count += min count min int min2 = Math.min(A[i + 1], B[i]); min2 Math.min(A[i + 1], B[i]) Math.min Math A[i + 1] A i + 1 i 1 B[i] B i A[i + 1] -= min2 A[i + 1] A i + 1 i 1 min2 B[i] -= min2 B[i] B i min2 count += min2 count min2 System.out.println(count) System.out.println System.out System System.out count String args[] args public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] A = new int[N + 1];
            for (int i = 0; i < N + 1; i++) {
                A[i] = in.nextInt();
            }
            int[] B = new int[N];
            for (int i = 0; i < N; i++) {
                B[i] = in.nextInt();
            }

            long count = 0;
            for (int i = 0; i < N; i++) {
                int min = Math.min(A[i], B[i]);
                A[i] -= min;
                B[i] -= min;
                count += min;

                int min2 = Math.min(A[i + 1], B[i]);
                A[i + 1] -= min2;
                B[i] -= min2;
                count += min2;
            }
            System.out.println(count);
        }
    }
} public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] A = new int[N + 1];
            for (int i = 0; i < N + 1; i++) {
                A[i] = in.nextInt();
            }
            int[] B = new int[N];
            for (int i = 0; i < N; i++) {
                B[i] = in.nextInt();
            }

            long count = 0;
            for (int i = 0; i < N; i++) {
                int min = Math.min(A[i], B[i]);
                A[i] -= min;
                B[i] -= min;
                count += min;

                int min2 = Math.min(A[i + 1], B[i]);
                A[i + 1] -= min2;
                B[i] -= min2;
                count += min2;
            }
            System.out.println(count);
        }
    }
} Main
import java.util.Scanner;

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

            long count = 0;
            for (int i = 0; i < N; i++) {
                int min = Math.min(A[i], B[i]);
                A[i] -= min;
                B[i] -= min;
                count += min;

                int min2 = Math.min(A[i + 1], B[i]);
                A[i + 1] -= min2;
                B[i] -= min2;
                count += min2;
            }
            System.out.println(count);
        }
    }
}
