
import java.util.Scanner;

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

                if(h[i]>0){
                    if(h[i]>=m[i+1]){
                        count+=m[i+1];
                        //System.out.println(count);
                        m[i+1]=0;
                       // h[i]=0;

                    }else{
                        m[i+1]-=h[i];
                        count+=h[i];
                        //System.out.println("Yo"+count + " " + h[i]);
                    }

                }

            }else{
                m[i]-=h[i];
                count+=h[i];
                //System.out.println(count);
            }
        }
        System.out.println(count);

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

                if(h[i]>0){
                    if(h[i]>=m[i+1]){
                        count+=m[i+1];
                        //System.out.println(count);
                        m[i+1]=0;
                       // h[i]=0;

                    }else{
                        m[i+1]-=h[i];
                        count+=h[i];
                        //System.out.println("Yo"+count + " " + h[i]);
                    }

                }

            }else{
                m[i]-=h[i];
                count+=h[i];
                //System.out.println(count);
            }
        }
        System.out.println(count);

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

                if(h[i]>0){
                    if(h[i]>=m[i+1]){
                        count+=m[i+1];
                        //System.out.println(count);
                        m[i+1]=0;
                       // h[i]=0;

                    }else{
                        m[i+1]-=h[i];
                        count+=h[i];
                        //System.out.println("Yo"+count + " " + h[i]);
                    }

                }

            }else{
                m[i]-=h[i];
                count+=h[i];
                //System.out.println(count);
            }
        }
        System.out.println(count);

    } main {
        Scanner in = new Scanner(System.in);
        int n= in.nextInt();
        long[] m = new long[n+1];
        long[] h = new long[n];
        for(int i=0;i<=n;i++){
            m[i]=in.nextInt();
        }
        for(int i=0;i<n;i++){
            h[i]=in.nextInt();
        }
        long count=0;
        for(int i=0;i<n;i++){
            if(h[i]>=m[i]){
                count+=m[i];
                //System.out.println(count);
                h[i]=h[i]-m[i];
                m[i]=0;

                if(h[i]>0){
                    if(h[i]>=m[i+1]){
                        count+=m[i+1];
                        //System.out.println(count);
                        m[i+1]=0;
                       // h[i]=0;

                    }else{
                        m[i+1]-=h[i];
                        count+=h[i];
                        //System.out.println("Yo"+count + " " + h[i]);
                    }

                }

            }else{
                m[i]-=h[i];
                count+=h[i];
                //System.out.println(count);
            }
        }
        System.out.println(count);

    } Scanner in = new Scanner(System.in); in new Scanner(System.in) int n= in.nextInt(); n in.nextInt() in.nextInt in long[] m = new long[n+1]; m new long[n+1] n+1 n 1 long[] h = new long[n]; h new long[n] n for(int i=0;i<=n;i++){
            m[i]=in.nextInt();
        } int i=0; int i=0; i 0 i<=n i n i++ i++ i {
            m[i]=in.nextInt();
        } {
            m[i]=in.nextInt();
        } m[i]=in.nextInt() m[i] m i in.nextInt() in.nextInt in for(int i=0;i<n;i++){
            h[i]=in.nextInt();
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            h[i]=in.nextInt();
        } {
            h[i]=in.nextInt();
        } h[i]=in.nextInt() h[i] h i in.nextInt() in.nextInt in long count=0; count 0 for(int i=0;i<n;i++){
            if(h[i]>=m[i]){
                count+=m[i];
                //System.out.println(count);
                h[i]=h[i]-m[i];
                m[i]=0;

                if(h[i]>0){
                    if(h[i]>=m[i+1]){
                        count+=m[i+1];
                        //System.out.println(count);
                        m[i+1]=0;
                       // h[i]=0;

                    }else{
                        m[i+1]-=h[i];
                        count+=h[i];
                        //System.out.println("Yo"+count + " " + h[i]);
                    }

                }

            }else{
                m[i]-=h[i];
                count+=h[i];
                //System.out.println(count);
            }
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            if(h[i]>=m[i]){
                count+=m[i];
                //System.out.println(count);
                h[i]=h[i]-m[i];
                m[i]=0;

                if(h[i]>0){
                    if(h[i]>=m[i+1]){
                        count+=m[i+1];
                        //System.out.println(count);
                        m[i+1]=0;
                       // h[i]=0;

                    }else{
                        m[i+1]-=h[i];
                        count+=h[i];
                        //System.out.println("Yo"+count + " " + h[i]);
                    }

                }

            }else{
                m[i]-=h[i];
                count+=h[i];
                //System.out.println(count);
            }
        } {
            if(h[i]>=m[i]){
                count+=m[i];
                //System.out.println(count);
                h[i]=h[i]-m[i];
                m[i]=0;

                if(h[i]>0){
                    if(h[i]>=m[i+1]){
                        count+=m[i+1];
                        //System.out.println(count);
                        m[i+1]=0;
                       // h[i]=0;

                    }else{
                        m[i+1]-=h[i];
                        count+=h[i];
                        //System.out.println("Yo"+count + " " + h[i]);
                    }

                }

            }else{
                m[i]-=h[i];
                count+=h[i];
                //System.out.println(count);
            }
        } if(h[i]>=m[i]){
                count+=m[i];
                //System.out.println(count);
                h[i]=h[i]-m[i];
                m[i]=0;

                if(h[i]>0){
                    if(h[i]>=m[i+1]){
                        count+=m[i+1];
                        //System.out.println(count);
                        m[i+1]=0;
                       // h[i]=0;

                    }else{
                        m[i+1]-=h[i];
                        count+=h[i];
                        //System.out.println("Yo"+count + " " + h[i]);
                    }

                }

            }else{
                m[i]-=h[i];
                count+=h[i];
                //System.out.println(count);
            } h[i]>=m[i] h[i] h i m[i] m i {
                count+=m[i];
                //System.out.println(count);
                h[i]=h[i]-m[i];
                m[i]=0;

                if(h[i]>0){
                    if(h[i]>=m[i+1]){
                        count+=m[i+1];
                        //System.out.println(count);
                        m[i+1]=0;
                       // h[i]=0;

                    }else{
                        m[i+1]-=h[i];
                        count+=h[i];
                        //System.out.println("Yo"+count + " " + h[i]);
                    }

                }

            } count+=m[i] count m[i] m i h[i]=h[i]-m[i] h[i] h i h[i]-m[i] h[i] h i m[i] m i m[i]=0 m[i] m i 0 if(h[i]>0){
                    if(h[i]>=m[i+1]){
                        count+=m[i+1];
                        //System.out.println(count);
                        m[i+1]=0;
                       // h[i]=0;

                    }else{
                        m[i+1]-=h[i];
                        count+=h[i];
                        //System.out.println("Yo"+count + " " + h[i]);
                    }

                } h[i]>0 h[i] h i 0 {
                    if(h[i]>=m[i+1]){
                        count+=m[i+1];
                        //System.out.println(count);
                        m[i+1]=0;
                       // h[i]=0;

                    }else{
                        m[i+1]-=h[i];
                        count+=h[i];
                        //System.out.println("Yo"+count + " " + h[i]);
                    }

                } if(h[i]>=m[i+1]){
                        count+=m[i+1];
                        //System.out.println(count);
                        m[i+1]=0;
                       // h[i]=0;

                    }else{
                        m[i+1]-=h[i];
                        count+=h[i];
                        //System.out.println("Yo"+count + " " + h[i]);
                    } h[i]>=m[i+1] h[i] h i m[i+1] m i+1 i 1 {
                        count+=m[i+1];
                        //System.out.println(count);
                        m[i+1]=0;
                       // h[i]=0;

                    } count+=m[i+1] count m[i+1] m i+1 i 1 m[i+1]=0 m[i+1] m i+1 i 1 0 {
                        m[i+1]-=h[i];
                        count+=h[i];
                        //System.out.println("Yo"+count + " " + h[i]);
                    } m[i+1]-=h[i] m[i+1] m i+1 i 1 h[i] h i count+=h[i] count h[i] h i {
                m[i]-=h[i];
                count+=h[i];
                //System.out.println(count);
            } m[i]-=h[i] m[i] m i h[i] h i count+=h[i] count h[i] h i System.out.println(count) System.out.println System.out System System.out count String[] args args

import java.util.Scanner;

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

                if(h[i]>0){
                    if(h[i]>=m[i+1]){
                        count+=m[i+1];
                        //System.out.println(count);
                        m[i+1]=0;
                       // h[i]=0;

                    }else{
                        m[i+1]-=h[i];
                        count+=h[i];
                        //System.out.println("Yo"+count + " " + h[i]);
                    }

                }

            }else{
                m[i]-=h[i];
                count+=h[i];
                //System.out.println(count);
            }
        }
        System.out.println(count);

    }
}
