import java.util.Scanner;

public class Main {
    public static void main(String[] atrgs){
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] A = new int[N+1];
        int[] B = new int[N];
        for(int i = 0; i < N+1; i++) {
            A[i] = scanner.nextInt();
        }
        for(int i = 0; i < N; i++) {
            B[i] = scanner.nextInt();
        }

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

            int right = Math.min(A[i + 1], B[i]);
            count += right;
            A[i + 1] -= right;
            B[i] -= right;
        }
        System.out.println(count);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] atrgs){
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] A = new int[N+1];
        int[] B = new int[N];
        for(int i = 0; i < N+1; i++) {
            A[i] = scanner.nextInt();
        }
        for(int i = 0; i < N; i++) {
            B[i] = scanner.nextInt();
        }

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

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

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

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

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

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

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

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

            int right = Math.min(A[i + 1], B[i]);
            count += right;
            A[i + 1] -= right;
            B[i] -= right;
        } int left = Math.min(A[i], B[i]); left Math.min(A[i], B[i]) Math.min Math A[i] A i B[i] B i count += left count left A[i] -= left A[i] A i left B[i] -= left B[i] B i left int right = Math.min(A[i + 1], B[i]); right Math.min(A[i + 1], B[i]) Math.min Math A[i + 1] A i + 1 i 1 B[i] B i count += right count right A[i + 1] -= right A[i + 1] A i + 1 i 1 right B[i] -= right B[i] B i right System.out.println(count) System.out.println System.out System System.out count public class Main {
    public static void main(String[] atrgs){
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] A = new int[N+1];
        int[] B = new int[N];
        for(int i = 0; i < N+1; i++) {
            A[i] = scanner.nextInt();
        }
        for(int i = 0; i < N; i++) {
            B[i] = scanner.nextInt();
        }

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

            int right = Math.min(A[i + 1], B[i]);
            count += right;
            A[i + 1] -= right;
            B[i] -= right;
        }
        System.out.println(count);
    }
} public class Main {
    public static void main(String[] atrgs){
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] A = new int[N+1];
        int[] B = new int[N];
        for(int i = 0; i < N+1; i++) {
            A[i] = scanner.nextInt();
        }
        for(int i = 0; i < N; i++) {
            B[i] = scanner.nextInt();
        }

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

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

public class Main {
    public static void main(String[] atrgs){
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] A = new int[N+1];
        int[] B = new int[N];
        for(int i = 0; i < N+1; i++) {
            A[i] = scanner.nextInt();
        }
        for(int i = 0; i < N; i++) {
            B[i] = scanner.nextInt();
        }

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

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