import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N+1];
        int[] B = new int[N];

        for (int i = 0; i < N+1; i++) {
            A[i]=sc.nextInt();
        }
        for (int i = 0; i < N; i++) {
            B[i]=sc.nextInt();
        }

        long ans = 0;


        for (int i = 0; i < N; i++) {
            int b = Math.min(A[i],B[i]);
            ans+=b;
            int rest = B[i]-b;
            int b2 = Math.min(A[i+1],rest);
            ans+=b2;
            A[i+1] -=b2;
        }



        System.out.println(ans);

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

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N+1];
        int[] B = new int[N];

        for (int i = 0; i < N+1; i++) {
            A[i]=sc.nextInt();
        }
        for (int i = 0; i < N; i++) {
            B[i]=sc.nextInt();
        }

        long ans = 0;


        for (int i = 0; i < N; i++) {
            int b = Math.min(A[i],B[i]);
            ans+=b;
            int rest = B[i]-b;
            int b2 = Math.min(A[i+1],rest);
            ans+=b2;
            A[i+1] -=b2;
        }



        System.out.println(ans);

    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N+1];
        int[] B = new int[N];

        for (int i = 0; i < N+1; i++) {
            A[i]=sc.nextInt();
        }
        for (int i = 0; i < N; i++) {
            B[i]=sc.nextInt();
        }

        long ans = 0;


        for (int i = 0; i < N; i++) {
            int b = Math.min(A[i],B[i]);
            ans+=b;
            int rest = B[i]-b;
            int b2 = Math.min(A[i+1],rest);
            ans+=b2;
            A[i+1] -=b2;
        }



        System.out.println(ans);

    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N+1];
        int[] B = new int[N];

        for (int i = 0; i < N+1; i++) {
            A[i]=sc.nextInt();
        }
        for (int i = 0; i < N; i++) {
            B[i]=sc.nextInt();
        }

        long ans = 0;


        for (int i = 0; i < N; i++) {
            int b = Math.min(A[i],B[i]);
            ans+=b;
            int rest = B[i]-b;
            int b2 = Math.min(A[i+1],rest);
            ans+=b2;
            A[i+1] -=b2;
        }



        System.out.println(ans);

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc 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]=sc.nextInt();
        } int i = 0; int i = 0; i 0 i < N+1 i N+1 N 1 i++ i++ i {
            A[i]=sc.nextInt();
        } {
            A[i]=sc.nextInt();
        } A[i]=sc.nextInt() A[i] A i sc.nextInt() sc.nextInt sc for (int i = 0; i < N; i++) {
            B[i]=sc.nextInt();
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            B[i]=sc.nextInt();
        } {
            B[i]=sc.nextInt();
        } B[i]=sc.nextInt() B[i] B i sc.nextInt() sc.nextInt sc long ans = 0; ans 0 for (int i = 0; i < N; i++) {
            int b = Math.min(A[i],B[i]);
            ans+=b;
            int rest = B[i]-b;
            int b2 = Math.min(A[i+1],rest);
            ans+=b2;
            A[i+1] -=b2;
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            int b = Math.min(A[i],B[i]);
            ans+=b;
            int rest = B[i]-b;
            int b2 = Math.min(A[i+1],rest);
            ans+=b2;
            A[i+1] -=b2;
        } {
            int b = Math.min(A[i],B[i]);
            ans+=b;
            int rest = B[i]-b;
            int b2 = Math.min(A[i+1],rest);
            ans+=b2;
            A[i+1] -=b2;
        } int b = Math.min(A[i],B[i]); b Math.min(A[i],B[i]) Math.min Math A[i] A i B[i] B i ans+=b ans b int rest = B[i]-b; rest B[i]-b B[i] B i b int b2 = Math.min(A[i+1],rest); b2 Math.min(A[i+1],rest) Math.min Math A[i+1] A i+1 i 1 rest ans+=b2 ans b2 A[i+1] -=b2 A[i+1] A i+1 i 1 b2 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) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N+1];
        int[] B = new int[N];

        for (int i = 0; i < N+1; i++) {
            A[i]=sc.nextInt();
        }
        for (int i = 0; i < N; i++) {
            B[i]=sc.nextInt();
        }

        long ans = 0;


        for (int i = 0; i < N; i++) {
            int b = Math.min(A[i],B[i]);
            ans+=b;
            int rest = B[i]-b;
            int b2 = Math.min(A[i+1],rest);
            ans+=b2;
            A[i+1] -=b2;
        }



        System.out.println(ans);

    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N+1];
        int[] B = new int[N];

        for (int i = 0; i < N+1; i++) {
            A[i]=sc.nextInt();
        }
        for (int i = 0; i < N; i++) {
            B[i]=sc.nextInt();
        }

        long ans = 0;


        for (int i = 0; i < N; i++) {
            int b = Math.min(A[i],B[i]);
            ans+=b;
            int rest = B[i]-b;
            int b2 = Math.min(A[i+1],rest);
            ans+=b2;
            A[i+1] -=b2;
        }



        System.out.println(ans);

    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N+1];
        int[] B = new int[N];

        for (int i = 0; i < N+1; i++) {
            A[i]=sc.nextInt();
        }
        for (int i = 0; i < N; i++) {
            B[i]=sc.nextInt();
        }

        long ans = 0;


        for (int i = 0; i < N; i++) {
            int b = Math.min(A[i],B[i]);
            ans+=b;
            int rest = B[i]-b;
            int b2 = Math.min(A[i+1],rest);
            ans+=b2;
            A[i+1] -=b2;
        }



        System.out.println(ans);

    }
}
