import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int [] arr = new int[n + 1];
        long x = 0;
        for (int i = 0; i < n + 1; i++) arr[i] = scanner.nextInt();
        for (int i = 0; i < n; i++) {
            int num = scanner.nextInt();
            int mo = Math.min(arr[i], num);
            arr[i] -= mo;
            num -= mo;
            x += mo;

            if (num != 0) {
                mo = Math.min(arr[i + 1], num);
                arr[i + 1] -= mo;
                num -= mo;
                x += mo;
            }
        }

        System.out.println(x);

    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int [] arr = new int[n + 1];
        long x = 0;
        for (int i = 0; i < n + 1; i++) arr[i] = scanner.nextInt();
        for (int i = 0; i < n; i++) {
            int num = scanner.nextInt();
            int mo = Math.min(arr[i], num);
            arr[i] -= mo;
            num -= mo;
            x += mo;

            if (num != 0) {
                mo = Math.min(arr[i + 1], num);
                arr[i + 1] -= mo;
                num -= mo;
                x += mo;
            }
        }

        System.out.println(x);

    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int [] arr = new int[n + 1];
        long x = 0;
        for (int i = 0; i < n + 1; i++) arr[i] = scanner.nextInt();
        for (int i = 0; i < n; i++) {
            int num = scanner.nextInt();
            int mo = Math.min(arr[i], num);
            arr[i] -= mo;
            num -= mo;
            x += mo;

            if (num != 0) {
                mo = Math.min(arr[i + 1], num);
                arr[i + 1] -= mo;
                num -= mo;
                x += mo;
            }
        }

        System.out.println(x);

    } main {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int [] arr = new int[n + 1];
        long x = 0;
        for (int i = 0; i < n + 1; i++) arr[i] = scanner.nextInt();
        for (int i = 0; i < n; i++) {
            int num = scanner.nextInt();
            int mo = Math.min(arr[i], num);
            arr[i] -= mo;
            num -= mo;
            x += mo;

            if (num != 0) {
                mo = Math.min(arr[i + 1], num);
                arr[i + 1] -= mo;
                num -= mo;
                x += mo;
            }
        }

        System.out.println(x);

    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int [] arr = new int[n + 1]; arr new int[n + 1] n + 1 n 1 long x = 0; x 0 for (int i = 0; i < n + 1; i++) arr[i] = scanner.nextInt(); int i = 0; int i = 0; i 0 i < n + 1 i n + 1 n 1 i++ i++ i arr[i] = scanner.nextInt(); arr[i] = scanner.nextInt() arr[i] arr i scanner.nextInt() scanner.nextInt scanner for (int i = 0; i < n; i++) {
            int num = scanner.nextInt();
            int mo = Math.min(arr[i], num);
            arr[i] -= mo;
            num -= mo;
            x += mo;

            if (num != 0) {
                mo = Math.min(arr[i + 1], num);
                arr[i + 1] -= mo;
                num -= mo;
                x += mo;
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            int num = scanner.nextInt();
            int mo = Math.min(arr[i], num);
            arr[i] -= mo;
            num -= mo;
            x += mo;

            if (num != 0) {
                mo = Math.min(arr[i + 1], num);
                arr[i + 1] -= mo;
                num -= mo;
                x += mo;
            }
        } {
            int num = scanner.nextInt();
            int mo = Math.min(arr[i], num);
            arr[i] -= mo;
            num -= mo;
            x += mo;

            if (num != 0) {
                mo = Math.min(arr[i + 1], num);
                arr[i + 1] -= mo;
                num -= mo;
                x += mo;
            }
        } int num = scanner.nextInt(); num scanner.nextInt() scanner.nextInt scanner int mo = Math.min(arr[i], num); mo Math.min(arr[i], num) Math.min Math arr[i] arr i num arr[i] -= mo arr[i] arr i mo num -= mo num mo x += mo x mo if (num != 0) {
                mo = Math.min(arr[i + 1], num);
                arr[i + 1] -= mo;
                num -= mo;
                x += mo;
            } num != 0 num 0 {
                mo = Math.min(arr[i + 1], num);
                arr[i + 1] -= mo;
                num -= mo;
                x += mo;
            } mo = Math.min(arr[i + 1], num) mo Math.min(arr[i + 1], num) Math.min Math arr[i + 1] arr i + 1 i 1 num arr[i + 1] -= mo arr[i + 1] arr i + 1 i 1 mo num -= mo num mo x += mo x mo System.out.println(x) System.out.println System.out System System.out x String[] args args public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int [] arr = new int[n + 1];
        long x = 0;
        for (int i = 0; i < n + 1; i++) arr[i] = scanner.nextInt();
        for (int i = 0; i < n; i++) {
            int num = scanner.nextInt();
            int mo = Math.min(arr[i], num);
            arr[i] -= mo;
            num -= mo;
            x += mo;

            if (num != 0) {
                mo = Math.min(arr[i + 1], num);
                arr[i + 1] -= mo;
                num -= mo;
                x += mo;
            }
        }

        System.out.println(x);

    }
} public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int [] arr = new int[n + 1];
        long x = 0;
        for (int i = 0; i < n + 1; i++) arr[i] = scanner.nextInt();
        for (int i = 0; i < n; i++) {
            int num = scanner.nextInt();
            int mo = Math.min(arr[i], num);
            arr[i] -= mo;
            num -= mo;
            x += mo;

            if (num != 0) {
                mo = Math.min(arr[i + 1], num);
                arr[i + 1] -= mo;
                num -= mo;
                x += mo;
            }
        }

        System.out.println(x);

    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int [] arr = new int[n + 1];
        long x = 0;
        for (int i = 0; i < n + 1; i++) arr[i] = scanner.nextInt();
        for (int i = 0; i < n; i++) {
            int num = scanner.nextInt();
            int mo = Math.min(arr[i], num);
            arr[i] -= mo;
            num -= mo;
            x += mo;

            if (num != 0) {
                mo = Math.min(arr[i + 1], num);
                arr[i + 1] -= mo;
                num -= mo;
                x += mo;
            }
        }

        System.out.println(x);

    }
}
