import java.util.*;

public class Main {

    public static void main(String[] args) {
        //Compute c1 = new Compute();//calc

        long count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();

        //input
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        long a[]=new long[n+1];
        long b[]=new long[n];
        for (int i=0;i<n+1;++i) a[i]=sc.nextLong();
        for (int i=0;i<n;++i) b[i]=sc.nextLong();

        for (int i=0;i<n;++i)
        {
            long rp=b[i]-a[i];
            if (rp<=0)
            {
                count+=b[i];
            }else
            {
                count+=a[i];
                long rp2=a[i+1]-rp;
                if (rp2<=0)
                {
                    count+=a[i+1];
                    a[i+1]=0;
                }else
                {
                    a[i+1]=rp2;
                    count+=rp;
                }
            }
        }
        System.out.println(count);
        //output
        //System.out.println(String.format("%.0f",answer));
    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
        //Compute c1 = new Compute();//calc

        long count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();

        //input
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        long a[]=new long[n+1];
        long b[]=new long[n];
        for (int i=0;i<n+1;++i) a[i]=sc.nextLong();
        for (int i=0;i<n;++i) b[i]=sc.nextLong();

        for (int i=0;i<n;++i)
        {
            long rp=b[i]-a[i];
            if (rp<=0)
            {
                count+=b[i];
            }else
            {
                count+=a[i];
                long rp2=a[i+1]-rp;
                if (rp2<=0)
                {
                    count+=a[i+1];
                    a[i+1]=0;
                }else
                {
                    a[i+1]=rp2;
                    count+=rp;
                }
            }
        }
        System.out.println(count);
        //output
        //System.out.println(String.format("%.0f",answer));
    }
} Main public static void main(String[] args) {
        //Compute c1 = new Compute();//calc

        long count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();

        //input
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        long a[]=new long[n+1];
        long b[]=new long[n];
        for (int i=0;i<n+1;++i) a[i]=sc.nextLong();
        for (int i=0;i<n;++i) b[i]=sc.nextLong();

        for (int i=0;i<n;++i)
        {
            long rp=b[i]-a[i];
            if (rp<=0)
            {
                count+=b[i];
            }else
            {
                count+=a[i];
                long rp2=a[i+1]-rp;
                if (rp2<=0)
                {
                    count+=a[i+1];
                    a[i+1]=0;
                }else
                {
                    a[i+1]=rp2;
                    count+=rp;
                }
            }
        }
        System.out.println(count);
        //output
        //System.out.println(String.format("%.0f",answer));
    } main {
        //Compute c1 = new Compute();//calc

        long count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();

        //input
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        long a[]=new long[n+1];
        long b[]=new long[n];
        for (int i=0;i<n+1;++i) a[i]=sc.nextLong();
        for (int i=0;i<n;++i) b[i]=sc.nextLong();

        for (int i=0;i<n;++i)
        {
            long rp=b[i]-a[i];
            if (rp<=0)
            {
                count+=b[i];
            }else
            {
                count+=a[i];
                long rp2=a[i+1]-rp;
                if (rp2<=0)
                {
                    count+=a[i+1];
                    a[i+1]=0;
                }else
                {
                    a[i+1]=rp2;
                    count+=rp;
                }
            }
        }
        System.out.println(count);
        //output
        //System.out.println(String.format("%.0f",answer));
    } long count = 0; count 0 boolean sw = false; sw false int max = Integer.MIN_VALUE; max Integer.MIN_VALUE Integer Integer.MIN_VALUE int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE double dMax = Double.MIN_VALUE; dMax Double.MIN_VALUE Double Double.MIN_VALUE double dMin = Double.MAX_VALUE; dMin Double.MAX_VALUE Double Double.MAX_VALUE Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc long a[]=new long[n+1]; a new long[n+1] n+1 n 1 long b[]=new long[n]; b new long[n] n for (int i=0;i<n+1;++i) a[i]=sc.nextLong(); int i=0; int i=0; i 0 i<n+1 i n+1 n 1 ++i ++i i a[i]=sc.nextLong(); a[i]=sc.nextLong() a[i] a i sc.nextLong() sc.nextLong sc for (int i=0;i<n;++i) b[i]=sc.nextLong(); int i=0; int i=0; i 0 i<n i n ++i ++i i b[i]=sc.nextLong(); b[i]=sc.nextLong() b[i] b i sc.nextLong() sc.nextLong sc for (int i=0;i<n;++i)
        {
            long rp=b[i]-a[i];
            if (rp<=0)
            {
                count+=b[i];
            }else
            {
                count+=a[i];
                long rp2=a[i+1]-rp;
                if (rp2<=0)
                {
                    count+=a[i+1];
                    a[i+1]=0;
                }else
                {
                    a[i+1]=rp2;
                    count+=rp;
                }
            }
        } int i=0; int i=0; i 0 i<n i n ++i ++i i {
            long rp=b[i]-a[i];
            if (rp<=0)
            {
                count+=b[i];
            }else
            {
                count+=a[i];
                long rp2=a[i+1]-rp;
                if (rp2<=0)
                {
                    count+=a[i+1];
                    a[i+1]=0;
                }else
                {
                    a[i+1]=rp2;
                    count+=rp;
                }
            }
        } {
            long rp=b[i]-a[i];
            if (rp<=0)
            {
                count+=b[i];
            }else
            {
                count+=a[i];
                long rp2=a[i+1]-rp;
                if (rp2<=0)
                {
                    count+=a[i+1];
                    a[i+1]=0;
                }else
                {
                    a[i+1]=rp2;
                    count+=rp;
                }
            }
        } long rp=b[i]-a[i]; rp b[i]-a[i] b[i] b i a[i] a i if (rp<=0)
            {
                count+=b[i];
            }else
            {
                count+=a[i];
                long rp2=a[i+1]-rp;
                if (rp2<=0)
                {
                    count+=a[i+1];
                    a[i+1]=0;
                }else
                {
                    a[i+1]=rp2;
                    count+=rp;
                }
            } rp<=0 rp 0 {
                count+=b[i];
            } count+=b[i] count b[i] b i {
                count+=a[i];
                long rp2=a[i+1]-rp;
                if (rp2<=0)
                {
                    count+=a[i+1];
                    a[i+1]=0;
                }else
                {
                    a[i+1]=rp2;
                    count+=rp;
                }
            } count+=a[i] count a[i] a i long rp2=a[i+1]-rp; rp2 a[i+1]-rp a[i+1] a i+1 i 1 rp if (rp2<=0)
                {
                    count+=a[i+1];
                    a[i+1]=0;
                }else
                {
                    a[i+1]=rp2;
                    count+=rp;
                } rp2<=0 rp2 0 {
                    count+=a[i+1];
                    a[i+1]=0;
                } count+=a[i+1] count a[i+1] a i+1 i 1 a[i+1]=0 a[i+1] a i+1 i 1 0 {
                    a[i+1]=rp2;
                    count+=rp;
                } a[i+1]=rp2 a[i+1] a i+1 i 1 rp2 count+=rp count rp System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {

    public static void main(String[] args) {
        //Compute c1 = new Compute();//calc

        long count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();

        //input
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        long a[]=new long[n+1];
        long b[]=new long[n];
        for (int i=0;i<n+1;++i) a[i]=sc.nextLong();
        for (int i=0;i<n;++i) b[i]=sc.nextLong();

        for (int i=0;i<n;++i)
        {
            long rp=b[i]-a[i];
            if (rp<=0)
            {
                count+=b[i];
            }else
            {
                count+=a[i];
                long rp2=a[i+1]-rp;
                if (rp2<=0)
                {
                    count+=a[i+1];
                    a[i+1]=0;
                }else
                {
                    a[i+1]=rp2;
                    count+=rp;
                }
            }
        }
        System.out.println(count);
        //output
        //System.out.println(String.format("%.0f",answer));
    }
} public class Main {

    public static void main(String[] args) {
        //Compute c1 = new Compute();//calc

        long count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();

        //input
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        long a[]=new long[n+1];
        long b[]=new long[n];
        for (int i=0;i<n+1;++i) a[i]=sc.nextLong();
        for (int i=0;i<n;++i) b[i]=sc.nextLong();

        for (int i=0;i<n;++i)
        {
            long rp=b[i]-a[i];
            if (rp<=0)
            {
                count+=b[i];
            }else
            {
                count+=a[i];
                long rp2=a[i+1]-rp;
                if (rp2<=0)
                {
                    count+=a[i+1];
                    a[i+1]=0;
                }else
                {
                    a[i+1]=rp2;
                    count+=rp;
                }
            }
        }
        System.out.println(count);
        //output
        //System.out.println(String.format("%.0f",answer));
    }
} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {
        //Compute c1 = new Compute();//calc

        long count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();

        //input
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        long a[]=new long[n+1];
        long b[]=new long[n];
        for (int i=0;i<n+1;++i) a[i]=sc.nextLong();
        for (int i=0;i<n;++i) b[i]=sc.nextLong();

        for (int i=0;i<n;++i)
        {
            long rp=b[i]-a[i];
            if (rp<=0)
            {
                count+=b[i];
            }else
            {
                count+=a[i];
                long rp2=a[i+1]-rp;
                if (rp2<=0)
                {
                    count+=a[i+1];
                    a[i+1]=0;
                }else
                {
                    a[i+1]=rp2;
                    count+=rp;
                }
            }
        }
        System.out.println(count);
        //output
        //System.out.println(String.format("%.0f",answer));
    }
}
