import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int n1 = n+1;
        long m[] = new long[n1];
        long h[] = new long[n];
        for (int i = 0; i < n1; i++) {
            m[i] = scan.nextInt();
        }
        for (int i = 0; i < n; i++) {
            h[i] = scan.nextInt();
        }

        long result = 0;
        for (int i = 0; i < n; i++) {
            long xh = h[i];
            if(xh >= m[i]){
                result+=m[i];
                xh-=m[i];
               if(xh>=m[i+1]){
                   result+=m[i+1];
                   m[i+1]=0;
               }else{
                   result+=xh;
                   m[i+1]-=xh;
               }
            }else{
                m[i]-=xh;
                result+=xh;
            }
        }

        System.out.println(result);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int n1 = n+1;
        long m[] = new long[n1];
        long h[] = new long[n];
        for (int i = 0; i < n1; i++) {
            m[i] = scan.nextInt();
        }
        for (int i = 0; i < n; i++) {
            h[i] = scan.nextInt();
        }

        long result = 0;
        for (int i = 0; i < n; i++) {
            long xh = h[i];
            if(xh >= m[i]){
                result+=m[i];
                xh-=m[i];
               if(xh>=m[i+1]){
                   result+=m[i+1];
                   m[i+1]=0;
               }else{
                   result+=xh;
                   m[i+1]-=xh;
               }
            }else{
                m[i]-=xh;
                result+=xh;
            }
        }

        System.out.println(result);
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int n1 = n+1;
        long m[] = new long[n1];
        long h[] = new long[n];
        for (int i = 0; i < n1; i++) {
            m[i] = scan.nextInt();
        }
        for (int i = 0; i < n; i++) {
            h[i] = scan.nextInt();
        }

        long result = 0;
        for (int i = 0; i < n; i++) {
            long xh = h[i];
            if(xh >= m[i]){
                result+=m[i];
                xh-=m[i];
               if(xh>=m[i+1]){
                   result+=m[i+1];
                   m[i+1]=0;
               }else{
                   result+=xh;
                   m[i+1]-=xh;
               }
            }else{
                m[i]-=xh;
                result+=xh;
            }
        }

        System.out.println(result);
    } main {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int n1 = n+1;
        long m[] = new long[n1];
        long h[] = new long[n];
        for (int i = 0; i < n1; i++) {
            m[i] = scan.nextInt();
        }
        for (int i = 0; i < n; i++) {
            h[i] = scan.nextInt();
        }

        long result = 0;
        for (int i = 0; i < n; i++) {
            long xh = h[i];
            if(xh >= m[i]){
                result+=m[i];
                xh-=m[i];
               if(xh>=m[i+1]){
                   result+=m[i+1];
                   m[i+1]=0;
               }else{
                   result+=xh;
                   m[i+1]-=xh;
               }
            }else{
                m[i]-=xh;
                result+=xh;
            }
        }

        System.out.println(result);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int n1 = n+1; n1 n+1 n 1 long m[] = new long[n1]; m new long[n1] n1 long h[] = new long[n]; h new long[n] n for (int i = 0; i < n1; i++) {
            m[i] = scan.nextInt();
        } int i = 0; int i = 0; i 0 i < n1 i n1 i++ i++ i {
            m[i] = scan.nextInt();
        } {
            m[i] = scan.nextInt();
        } m[i] = scan.nextInt() m[i] m i scan.nextInt() scan.nextInt scan for (int i = 0; i < n; i++) {
            h[i] = scan.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            h[i] = scan.nextInt();
        } {
            h[i] = scan.nextInt();
        } h[i] = scan.nextInt() h[i] h i scan.nextInt() scan.nextInt scan long result = 0; result 0 for (int i = 0; i < n; i++) {
            long xh = h[i];
            if(xh >= m[i]){
                result+=m[i];
                xh-=m[i];
               if(xh>=m[i+1]){
                   result+=m[i+1];
                   m[i+1]=0;
               }else{
                   result+=xh;
                   m[i+1]-=xh;
               }
            }else{
                m[i]-=xh;
                result+=xh;
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            long xh = h[i];
            if(xh >= m[i]){
                result+=m[i];
                xh-=m[i];
               if(xh>=m[i+1]){
                   result+=m[i+1];
                   m[i+1]=0;
               }else{
                   result+=xh;
                   m[i+1]-=xh;
               }
            }else{
                m[i]-=xh;
                result+=xh;
            }
        } {
            long xh = h[i];
            if(xh >= m[i]){
                result+=m[i];
                xh-=m[i];
               if(xh>=m[i+1]){
                   result+=m[i+1];
                   m[i+1]=0;
               }else{
                   result+=xh;
                   m[i+1]-=xh;
               }
            }else{
                m[i]-=xh;
                result+=xh;
            }
        } long xh = h[i]; xh h[i] h i if(xh >= m[i]){
                result+=m[i];
                xh-=m[i];
               if(xh>=m[i+1]){
                   result+=m[i+1];
                   m[i+1]=0;
               }else{
                   result+=xh;
                   m[i+1]-=xh;
               }
            }else{
                m[i]-=xh;
                result+=xh;
            } xh >= m[i] xh m[i] m i {
                result+=m[i];
                xh-=m[i];
               if(xh>=m[i+1]){
                   result+=m[i+1];
                   m[i+1]=0;
               }else{
                   result+=xh;
                   m[i+1]-=xh;
               }
            } result+=m[i] result m[i] m i xh-=m[i] xh m[i] m i if(xh>=m[i+1]){
                   result+=m[i+1];
                   m[i+1]=0;
               }else{
                   result+=xh;
                   m[i+1]-=xh;
               } xh>=m[i+1] xh m[i+1] m i+1 i 1 {
                   result+=m[i+1];
                   m[i+1]=0;
               } result+=m[i+1] result m[i+1] m i+1 i 1 m[i+1]=0 m[i+1] m i+1 i 1 0 {
                   result+=xh;
                   m[i+1]-=xh;
               } result+=xh result xh m[i+1]-=xh m[i+1] m i+1 i 1 xh {
                m[i]-=xh;
                result+=xh;
            } m[i]-=xh m[i] m i xh result+=xh result xh System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int n1 = n+1;
        long m[] = new long[n1];
        long h[] = new long[n];
        for (int i = 0; i < n1; i++) {
            m[i] = scan.nextInt();
        }
        for (int i = 0; i < n; i++) {
            h[i] = scan.nextInt();
        }

        long result = 0;
        for (int i = 0; i < n; i++) {
            long xh = h[i];
            if(xh >= m[i]){
                result+=m[i];
                xh-=m[i];
               if(xh>=m[i+1]){
                   result+=m[i+1];
                   m[i+1]=0;
               }else{
                   result+=xh;
                   m[i+1]-=xh;
               }
            }else{
                m[i]-=xh;
                result+=xh;
            }
        }

        System.out.println(result);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int n1 = n+1;
        long m[] = new long[n1];
        long h[] = new long[n];
        for (int i = 0; i < n1; i++) {
            m[i] = scan.nextInt();
        }
        for (int i = 0; i < n; i++) {
            h[i] = scan.nextInt();
        }

        long result = 0;
        for (int i = 0; i < n; i++) {
            long xh = h[i];
            if(xh >= m[i]){
                result+=m[i];
                xh-=m[i];
               if(xh>=m[i+1]){
                   result+=m[i+1];
                   m[i+1]=0;
               }else{
                   result+=xh;
                   m[i+1]-=xh;
               }
            }else{
                m[i]-=xh;
                result+=xh;
            }
        }

        System.out.println(result);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int n1 = n+1;
        long m[] = new long[n1];
        long h[] = new long[n];
        for (int i = 0; i < n1; i++) {
            m[i] = scan.nextInt();
        }
        for (int i = 0; i < n; i++) {
            h[i] = scan.nextInt();
        }

        long result = 0;
        for (int i = 0; i < n; i++) {
            long xh = h[i];
            if(xh >= m[i]){
                result+=m[i];
                xh-=m[i];
               if(xh>=m[i+1]){
                   result+=m[i+1];
                   m[i+1]=0;
               }else{
                   result+=xh;
                   m[i+1]-=xh;
               }
            }else{
                m[i]-=xh;
                result+=xh;
            }
        }

        System.out.println(result);
    }
}
