import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int N = Integer.parseInt(reader.readLine());

            String[] array = reader.readLine().split(" ");
            int[] A = new int[N + 1];
            for (int i = 0; i < N + 1; i++) {
                A[i] = Integer.parseInt(array[i]);
            }

            array = reader.readLine().split(" ");
            int[] B = new int[N];
            for (int i = 0; i < N; i++) {
                B[i] = Integer.parseInt(array[i]);
            }

            long ans = 0;
            for (int i = 0; i < N; i++) {
                if (A[i] >= B[i]) {
                    ans += B[i];
                } else {
                    ans += A[i];
                    if (A[i + 1] >= (B[i] - A[i])) {
                        ans += B[i] - A[i];
                        A[i + 1] -= B[i] - A[i];
                    } else {
                        ans += A[i + 1];
                        A[i + 1] = 0;
                    }
                }
            }

            System.out.println(ans);
        }
    }

} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int N = Integer.parseInt(reader.readLine());

            String[] array = reader.readLine().split(" ");
            int[] A = new int[N + 1];
            for (int i = 0; i < N + 1; i++) {
                A[i] = Integer.parseInt(array[i]);
            }

            array = reader.readLine().split(" ");
            int[] B = new int[N];
            for (int i = 0; i < N; i++) {
                B[i] = Integer.parseInt(array[i]);
            }

            long ans = 0;
            for (int i = 0; i < N; i++) {
                if (A[i] >= B[i]) {
                    ans += B[i];
                } else {
                    ans += A[i];
                    if (A[i + 1] >= (B[i] - A[i])) {
                        ans += B[i] - A[i];
                        A[i + 1] -= B[i] - A[i];
                    } else {
                        ans += A[i + 1];
                        A[i + 1] = 0;
                    }
                }
            }

            System.out.println(ans);
        }
    }

} Main public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int N = Integer.parseInt(reader.readLine());

            String[] array = reader.readLine().split(" ");
            int[] A = new int[N + 1];
            for (int i = 0; i < N + 1; i++) {
                A[i] = Integer.parseInt(array[i]);
            }

            array = reader.readLine().split(" ");
            int[] B = new int[N];
            for (int i = 0; i < N; i++) {
                B[i] = Integer.parseInt(array[i]);
            }

            long ans = 0;
            for (int i = 0; i < N; i++) {
                if (A[i] >= B[i]) {
                    ans += B[i];
                } else {
                    ans += A[i];
                    if (A[i + 1] >= (B[i] - A[i])) {
                        ans += B[i] - A[i];
                        A[i + 1] -= B[i] - A[i];
                    } else {
                        ans += A[i + 1];
                        A[i + 1] = 0;
                    }
                }
            }

            System.out.println(ans);
        }
    } main {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int N = Integer.parseInt(reader.readLine());

            String[] array = reader.readLine().split(" ");
            int[] A = new int[N + 1];
            for (int i = 0; i < N + 1; i++) {
                A[i] = Integer.parseInt(array[i]);
            }

            array = reader.readLine().split(" ");
            int[] B = new int[N];
            for (int i = 0; i < N; i++) {
                B[i] = Integer.parseInt(array[i]);
            }

            long ans = 0;
            for (int i = 0; i < N; i++) {
                if (A[i] >= B[i]) {
                    ans += B[i];
                } else {
                    ans += A[i];
                    if (A[i + 1] >= (B[i] - A[i])) {
                        ans += B[i] - A[i];
                        A[i + 1] -= B[i] - A[i];
                    } else {
                        ans += A[i + 1];
                        A[i + 1] = 0;
                    }
                }
            }

            System.out.println(ans);
        }
    } try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int N = Integer.parseInt(reader.readLine());

            String[] array = reader.readLine().split(" ");
            int[] A = new int[N + 1];
            for (int i = 0; i < N + 1; i++) {
                A[i] = Integer.parseInt(array[i]);
            }

            array = reader.readLine().split(" ");
            int[] B = new int[N];
            for (int i = 0; i < N; i++) {
                B[i] = Integer.parseInt(array[i]);
            }

            long ans = 0;
            for (int i = 0; i < N; i++) {
                if (A[i] >= B[i]) {
                    ans += B[i];
                } else {
                    ans += A[i];
                    if (A[i + 1] >= (B[i] - A[i])) {
                        ans += B[i] - A[i];
                        A[i + 1] -= B[i] - A[i];
                    } else {
                        ans += A[i + 1];
                        A[i + 1] = 0;
                    }
                }
            }

            System.out.println(ans);
        } {
            int N = Integer.parseInt(reader.readLine());

            String[] array = reader.readLine().split(" ");
            int[] A = new int[N + 1];
            for (int i = 0; i < N + 1; i++) {
                A[i] = Integer.parseInt(array[i]);
            }

            array = reader.readLine().split(" ");
            int[] B = new int[N];
            for (int i = 0; i < N; i++) {
                B[i] = Integer.parseInt(array[i]);
            }

            long ans = 0;
            for (int i = 0; i < N; i++) {
                if (A[i] >= B[i]) {
                    ans += B[i];
                } else {
                    ans += A[i];
                    if (A[i + 1] >= (B[i] - A[i])) {
                        ans += B[i] - A[i];
                        A[i + 1] -= B[i] - A[i];
                    } else {
                        ans += A[i + 1];
                        A[i + 1] = 0;
                    }
                }
            }

            System.out.println(ans);
        } BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)) BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)) new BufferedReader(new InputStreamReader(System.in)) int N = Integer.parseInt(reader.readLine()); N Integer.parseInt(reader.readLine()) Integer.parseInt Integer reader.readLine() reader.readLine reader String[] array = reader.readLine().split(" "); array reader.readLine().split(" ") reader.readLine().split reader.readLine() reader.readLine reader " " 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] = Integer.parseInt(array[i]);
            } int i = 0; int i = 0; i 0 i < N + 1 i N + 1 N 1 i++ i++ i {
                A[i] = Integer.parseInt(array[i]);
            } {
                A[i] = Integer.parseInt(array[i]);
            } A[i] = Integer.parseInt(array[i]) A[i] A i Integer.parseInt(array[i]) Integer.parseInt Integer array[i] array i array = reader.readLine().split(" ") array reader.readLine().split(" ") reader.readLine().split reader.readLine() reader.readLine reader " " int[] B = new int[N]; B new int[N] N for (int i = 0; i < N; i++) {
                B[i] = Integer.parseInt(array[i]);
            } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
                B[i] = Integer.parseInt(array[i]);
            } {
                B[i] = Integer.parseInt(array[i]);
            } B[i] = Integer.parseInt(array[i]) B[i] B i Integer.parseInt(array[i]) Integer.parseInt Integer array[i] array i long ans = 0; ans 0 for (int i = 0; i < N; i++) {
                if (A[i] >= B[i]) {
                    ans += B[i];
                } else {
                    ans += A[i];
                    if (A[i + 1] >= (B[i] - A[i])) {
                        ans += B[i] - A[i];
                        A[i + 1] -= B[i] - A[i];
                    } else {
                        ans += A[i + 1];
                        A[i + 1] = 0;
                    }
                }
            } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
                if (A[i] >= B[i]) {
                    ans += B[i];
                } else {
                    ans += A[i];
                    if (A[i + 1] >= (B[i] - A[i])) {
                        ans += B[i] - A[i];
                        A[i + 1] -= B[i] - A[i];
                    } else {
                        ans += A[i + 1];
                        A[i + 1] = 0;
                    }
                }
            } {
                if (A[i] >= B[i]) {
                    ans += B[i];
                } else {
                    ans += A[i];
                    if (A[i + 1] >= (B[i] - A[i])) {
                        ans += B[i] - A[i];
                        A[i + 1] -= B[i] - A[i];
                    } else {
                        ans += A[i + 1];
                        A[i + 1] = 0;
                    }
                }
            } if (A[i] >= B[i]) {
                    ans += B[i];
                } else {
                    ans += A[i];
                    if (A[i + 1] >= (B[i] - A[i])) {
                        ans += B[i] - A[i];
                        A[i + 1] -= B[i] - A[i];
                    } else {
                        ans += A[i + 1];
                        A[i + 1] = 0;
                    }
                } A[i] >= B[i] A[i] A i B[i] B i {
                    ans += B[i];
                } ans += B[i] ans B[i] B i {
                    ans += A[i];
                    if (A[i + 1] >= (B[i] - A[i])) {
                        ans += B[i] - A[i];
                        A[i + 1] -= B[i] - A[i];
                    } else {
                        ans += A[i + 1];
                        A[i + 1] = 0;
                    }
                } ans += A[i] ans A[i] A i if (A[i + 1] >= (B[i] - A[i])) {
                        ans += B[i] - A[i];
                        A[i + 1] -= B[i] - A[i];
                    } else {
                        ans += A[i + 1];
                        A[i + 1] = 0;
                    } A[i + 1] >= (B[i] - A[i]) A[i + 1] A i + 1 i 1 (B[i] - A[i]) B[i] B i A[i] A i {
                        ans += B[i] - A[i];
                        A[i + 1] -= B[i] - A[i];
                    } ans += B[i] - A[i] ans B[i] - A[i] B[i] B i A[i] A i A[i + 1] -= B[i] - A[i] A[i + 1] A i + 1 i 1 B[i] - A[i] B[i] B i A[i] A i {
                        ans += A[i + 1];
                        A[i + 1] = 0;
                    } ans += A[i + 1] ans A[i + 1] A i + 1 i 1 A[i + 1] = 0 A[i + 1] A i + 1 i 1 0 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int N = Integer.parseInt(reader.readLine());

            String[] array = reader.readLine().split(" ");
            int[] A = new int[N + 1];
            for (int i = 0; i < N + 1; i++) {
                A[i] = Integer.parseInt(array[i]);
            }

            array = reader.readLine().split(" ");
            int[] B = new int[N];
            for (int i = 0; i < N; i++) {
                B[i] = Integer.parseInt(array[i]);
            }

            long ans = 0;
            for (int i = 0; i < N; i++) {
                if (A[i] >= B[i]) {
                    ans += B[i];
                } else {
                    ans += A[i];
                    if (A[i + 1] >= (B[i] - A[i])) {
                        ans += B[i] - A[i];
                        A[i + 1] -= B[i] - A[i];
                    } else {
                        ans += A[i + 1];
                        A[i + 1] = 0;
                    }
                }
            }

            System.out.println(ans);
        }
    }

} public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int N = Integer.parseInt(reader.readLine());

            String[] array = reader.readLine().split(" ");
            int[] A = new int[N + 1];
            for (int i = 0; i < N + 1; i++) {
                A[i] = Integer.parseInt(array[i]);
            }

            array = reader.readLine().split(" ");
            int[] B = new int[N];
            for (int i = 0; i < N; i++) {
                B[i] = Integer.parseInt(array[i]);
            }

            long ans = 0;
            for (int i = 0; i < N; i++) {
                if (A[i] >= B[i]) {
                    ans += B[i];
                } else {
                    ans += A[i];
                    if (A[i + 1] >= (B[i] - A[i])) {
                        ans += B[i] - A[i];
                        A[i + 1] -= B[i] - A[i];
                    } else {
                        ans += A[i + 1];
                        A[i + 1] = 0;
                    }
                }
            }

            System.out.println(ans);
        }
    }

} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int N = Integer.parseInt(reader.readLine());

            String[] array = reader.readLine().split(" ");
            int[] A = new int[N + 1];
            for (int i = 0; i < N + 1; i++) {
                A[i] = Integer.parseInt(array[i]);
            }

            array = reader.readLine().split(" ");
            int[] B = new int[N];
            for (int i = 0; i < N; i++) {
                B[i] = Integer.parseInt(array[i]);
            }

            long ans = 0;
            for (int i = 0; i < N; i++) {
                if (A[i] >= B[i]) {
                    ans += B[i];
                } else {
                    ans += A[i];
                    if (A[i + 1] >= (B[i] - A[i])) {
                        ans += B[i] - A[i];
                        A[i + 1] -= B[i] - A[i];
                    } else {
                        ans += A[i + 1];
                        A[i + 1] = 0;
                    }
                }
            }

            System.out.println(ans);
        }
    }

}
