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
 *
 * @author teiwa
 */
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);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            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 answer = 0;
            for (int i = n - 1; i >= 0; i--) {
                if (b[i] >= a[i + 1]) {
                    answer += a[i + 1];
                    b[i] -= a[i + 1];
                    if (b[i] <= a[i]) {
                        a[i] -= b[i];
                        answer += b[i];
                    } else {
                        answer += a[i];
                        a[i] = 0;
                    }
                } else {
                    answer += b[i];
                }
            }
            out.println(answer);
        }

    }
}
 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);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            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 answer = 0;
            for (int i = n - 1; i >= 0; i--) {
                if (b[i] >= a[i + 1]) {
                    answer += a[i + 1];
                    b[i] -= a[i + 1];
                    if (b[i] <= a[i]) {
                        a[i] -= b[i];
                        answer += b[i];
                    } else {
                        answer += a[i];
                        a[i] = 0;
                    }
                } else {
                    answer += b[i];
                }
            }
            out.println(answer);
        }

    }
} 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);
        TaskC solver = new TaskC();
        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);
        TaskC solver = new TaskC();
        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) TaskC solver = new TaskC(); solver new TaskC() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            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 answer = 0;
            for (int i = n - 1; i >= 0; i--) {
                if (b[i] >= a[i + 1]) {
                    answer += a[i + 1];
                    b[i] -= a[i + 1];
                    if (b[i] <= a[i]) {
                        a[i] -= b[i];
                        answer += b[i];
                    } else {
                        answer += a[i];
                        a[i] = 0;
                    }
                } else {
                    answer += b[i];
                }
            }
            out.println(answer);
        }

    } TaskC public void solve(int testNumber, Scanner in, PrintWriter out) {
            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 answer = 0;
            for (int i = n - 1; i >= 0; i--) {
                if (b[i] >= a[i + 1]) {
                    answer += a[i + 1];
                    b[i] -= a[i + 1];
                    if (b[i] <= a[i]) {
                        a[i] -= b[i];
                        answer += b[i];
                    } else {
                        answer += a[i];
                        a[i] = 0;
                    }
                } else {
                    answer += b[i];
                }
            }
            out.println(answer);
        } solve {
            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 answer = 0;
            for (int i = n - 1; i >= 0; i--) {
                if (b[i] >= a[i + 1]) {
                    answer += a[i + 1];
                    b[i] -= a[i + 1];
                    if (b[i] <= a[i]) {
                        a[i] -= b[i];
                        answer += b[i];
                    } else {
                        answer += a[i];
                        a[i] = 0;
                    }
                } else {
                    answer += b[i];
                }
            }
            out.println(answer);
        } 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 answer = 0; answer 0 for (int i = n - 1; i >= 0; i--) {
                if (b[i] >= a[i + 1]) {
                    answer += a[i + 1];
                    b[i] -= a[i + 1];
                    if (b[i] <= a[i]) {
                        a[i] -= b[i];
                        answer += b[i];
                    } else {
                        answer += a[i];
                        a[i] = 0;
                    }
                } else {
                    answer += b[i];
                }
            } int i = n - 1; int i = n - 1; i n - 1 n 1 i >= 0 i 0 i-- i-- i {
                if (b[i] >= a[i + 1]) {
                    answer += a[i + 1];
                    b[i] -= a[i + 1];
                    if (b[i] <= a[i]) {
                        a[i] -= b[i];
                        answer += b[i];
                    } else {
                        answer += a[i];
                        a[i] = 0;
                    }
                } else {
                    answer += b[i];
                }
            } {
                if (b[i] >= a[i + 1]) {
                    answer += a[i + 1];
                    b[i] -= a[i + 1];
                    if (b[i] <= a[i]) {
                        a[i] -= b[i];
                        answer += b[i];
                    } else {
                        answer += a[i];
                        a[i] = 0;
                    }
                } else {
                    answer += b[i];
                }
            } if (b[i] >= a[i + 1]) {
                    answer += a[i + 1];
                    b[i] -= a[i + 1];
                    if (b[i] <= a[i]) {
                        a[i] -= b[i];
                        answer += b[i];
                    } else {
                        answer += a[i];
                        a[i] = 0;
                    }
                } else {
                    answer += b[i];
                } b[i] >= a[i + 1] b[i] b i a[i + 1] a i + 1 i 1 {
                    answer += a[i + 1];
                    b[i] -= a[i + 1];
                    if (b[i] <= a[i]) {
                        a[i] -= b[i];
                        answer += b[i];
                    } else {
                        answer += a[i];
                        a[i] = 0;
                    }
                } answer += a[i + 1] answer a[i + 1] a i + 1 i 1 b[i] -= a[i + 1] b[i] b i a[i + 1] a i + 1 i 1 if (b[i] <= a[i]) {
                        a[i] -= b[i];
                        answer += b[i];
                    } else {
                        answer += a[i];
                        a[i] = 0;
                    } b[i] <= a[i] b[i] b i a[i] a i {
                        a[i] -= b[i];
                        answer += b[i];
                    } a[i] -= b[i] a[i] a i b[i] b i answer += b[i] answer b[i] b i {
                        answer += a[i];
                        a[i] = 0;
                    } answer += a[i] answer a[i] a i a[i] = 0 a[i] a i 0 {
                    answer += b[i];
                } answer += b[i] answer b[i] b i out.println(answer) out.println out answer 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);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            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 answer = 0;
            for (int i = n - 1; i >= 0; i--) {
                if (b[i] >= a[i + 1]) {
                    answer += a[i + 1];
                    b[i] -= a[i + 1];
                    if (b[i] <= a[i]) {
                        a[i] -= b[i];
                        answer += b[i];
                    } else {
                        answer += a[i];
                        a[i] = 0;
                    }
                } else {
                    answer += b[i];
                }
            }
            out.println(answer);
        }

    }
} 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);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            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 answer = 0;
            for (int i = n - 1; i >= 0; i--) {
                if (b[i] >= a[i + 1]) {
                    answer += a[i + 1];
                    b[i] -= a[i + 1];
                    if (b[i] <= a[i]) {
                        a[i] -= b[i];
                        answer += b[i];
                    } else {
                        answer += a[i];
                        a[i] = 0;
                    }
                } else {
                    answer += b[i];
                }
            }
            out.println(answer);
        }

    }
} 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
 *
 * @author teiwa
 */
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);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            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 answer = 0;
            for (int i = n - 1; i >= 0; i--) {
                if (b[i] >= a[i + 1]) {
                    answer += a[i + 1];
                    b[i] -= a[i + 1];
                    if (b[i] <= a[i]) {
                        a[i] -= b[i];
                        answer += b[i];
                    } else {
                        answer += a[i];
                        a[i] = 0;
                    }
                } else {
                    answer += b[i];
                }
            }
            out.println(answer);
        }

    }
}

