import java.awt.*;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.ArrayList;
import java.util.Collections;

public class Main{
    public static void main(String args[] ) throws Exception {
        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;i++)a[i]=sc.nextInt();
        for(int i=0;i<n;i++)b[i]=sc.nextInt();

        long count=0;

        for(int i=n-1;i>=0;i--){
            for(int j=1;j>=0;j--){

                int x = a[i + j];
                int y = b[i];

                int m=Math.min(y,x);

                count=count+m;
                b[i]=b[i]-m;
                a[i+j]=a[i+j]-m;
            }
        }
        System.out.println(count);

    }

}
 import java.awt.*; awt.* java import java.util.Arrays; Arrays java.util import java.util.HashSet; HashSet java.util import java.util.Scanner; Scanner java.util import java.util.Set; Set java.util import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util public class Main{
    public static void main(String args[] ) throws Exception {
        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;i++)a[i]=sc.nextInt();
        for(int i=0;i<n;i++)b[i]=sc.nextInt();

        long count=0;

        for(int i=n-1;i>=0;i--){
            for(int j=1;j>=0;j--){

                int x = a[i + j];
                int y = b[i];

                int m=Math.min(y,x);

                count=count+m;
                b[i]=b[i]-m;
                a[i+j]=a[i+j]-m;
            }
        }
        System.out.println(count);

    }

} Main public static void main(String args[] ) throws Exception {
        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;i++)a[i]=sc.nextInt();
        for(int i=0;i<n;i++)b[i]=sc.nextInt();

        long count=0;

        for(int i=n-1;i>=0;i--){
            for(int j=1;j>=0;j--){

                int x = a[i + j];
                int y = b[i];

                int m=Math.min(y,x);

                count=count+m;
                b[i]=b[i]-m;
                a[i+j]=a[i+j]-m;
            }
        }
        System.out.println(count);

    } 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;i++)a[i]=sc.nextInt();
        for(int i=0;i<n;i++)b[i]=sc.nextInt();

        long count=0;

        for(int i=n-1;i>=0;i--){
            for(int j=1;j>=0;j--){

                int x = a[i + j];
                int y = b[i];

                int m=Math.min(y,x);

                count=count+m;
                b[i]=b[i]-m;
                a[i+j]=a[i+j]-m;
            }
        }
        System.out.println(count);

    } 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;i++)a[i]=sc.nextInt(); int i=0; int i=0; i 0 i<=n i n i++ i++ i 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] b i sc.nextInt() sc.nextInt sc long count=0; count 0 for(int i=n-1;i>=0;i--){
            for(int j=1;j>=0;j--){

                int x = a[i + j];
                int y = b[i];

                int m=Math.min(y,x);

                count=count+m;
                b[i]=b[i]-m;
                a[i+j]=a[i+j]-m;
            }
        } int i=n-1; int i=n-1; i n-1 n 1 i>=0 i 0 i-- i-- i {
            for(int j=1;j>=0;j--){

                int x = a[i + j];
                int y = b[i];

                int m=Math.min(y,x);

                count=count+m;
                b[i]=b[i]-m;
                a[i+j]=a[i+j]-m;
            }
        } {
            for(int j=1;j>=0;j--){

                int x = a[i + j];
                int y = b[i];

                int m=Math.min(y,x);

                count=count+m;
                b[i]=b[i]-m;
                a[i+j]=a[i+j]-m;
            }
        } for(int j=1;j>=0;j--){

                int x = a[i + j];
                int y = b[i];

                int m=Math.min(y,x);

                count=count+m;
                b[i]=b[i]-m;
                a[i+j]=a[i+j]-m;
            } int j=1; int j=1; j 1 j>=0 j 0 j-- j-- j {

                int x = a[i + j];
                int y = b[i];

                int m=Math.min(y,x);

                count=count+m;
                b[i]=b[i]-m;
                a[i+j]=a[i+j]-m;
            } {

                int x = a[i + j];
                int y = b[i];

                int m=Math.min(y,x);

                count=count+m;
                b[i]=b[i]-m;
                a[i+j]=a[i+j]-m;
            } int x = a[i + j]; x a[i + j] a i + j i j int y = b[i]; y b[i] b i int m=Math.min(y,x); m Math.min(y,x) Math.min Math y x count=count+m count count+m count m b[i]=b[i]-m b[i] b i b[i]-m b[i] b i m a[i+j]=a[i+j]-m a[i+j] a i+j i j a[i+j]-m a[i+j] a i+j i j m 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[] ) throws Exception {
        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;i++)a[i]=sc.nextInt();
        for(int i=0;i<n;i++)b[i]=sc.nextInt();

        long count=0;

        for(int i=n-1;i>=0;i--){
            for(int j=1;j>=0;j--){

                int x = a[i + j];
                int y = b[i];

                int m=Math.min(y,x);

                count=count+m;
                b[i]=b[i]-m;
                a[i+j]=a[i+j]-m;
            }
        }
        System.out.println(count);

    }

} public class Main{
    public static void main(String args[] ) throws Exception {
        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;i++)a[i]=sc.nextInt();
        for(int i=0;i<n;i++)b[i]=sc.nextInt();

        long count=0;

        for(int i=n-1;i>=0;i--){
            for(int j=1;j>=0;j--){

                int x = a[i + j];
                int y = b[i];

                int m=Math.min(y,x);

                count=count+m;
                b[i]=b[i]-m;
                a[i+j]=a[i+j]-m;
            }
        }
        System.out.println(count);

    }

} Main
import java.awt.*;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.ArrayList;
import java.util.Collections;

public class Main{
    public static void main(String args[] ) throws Exception {
        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;i++)a[i]=sc.nextInt();
        for(int i=0;i<n;i++)b[i]=sc.nextInt();

        long count=0;

        for(int i=n-1;i>=0;i--){
            for(int j=1;j>=0;j--){

                int x = a[i + j];
                int y = b[i];

                int m=Math.min(y,x);

                count=count+m;
                b[i]=b[i]-m;
                a[i+j]=a[i+j]-m;
            }
        }
        System.out.println(count);

    }

}

