import java.util.*; 

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 c=0;c<n+1;c++){
    		a[c]=sc.nextInt();
    	}
  		for(int c=0;c<n;c++){
        	b[c]=sc.nextInt();
        }
  		
  		long ans=0;
  		for(int d=0;d<n;d++){
        	if(a[d]<b[d]){
            	ans+=a[d];
              if(a[d+1]>b[d]-a[d]){
              	a[d+1]-=(b[d]-a[d]);
                ans+=(b[d]-a[d]);
              }else{
                ans+=a[d+1];
                a[d+1]=0;
              }
            }else{
            	ans+=b[d];
            }
        }
    
 	

    	System.out.println(ans);
    }
}
 import java.util.*; util.* java 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 c=0;c<n+1;c++){
    		a[c]=sc.nextInt();
    	}
  		for(int c=0;c<n;c++){
        	b[c]=sc.nextInt();
        }
  		
  		long ans=0;
  		for(int d=0;d<n;d++){
        	if(a[d]<b[d]){
            	ans+=a[d];
              if(a[d+1]>b[d]-a[d]){
              	a[d+1]-=(b[d]-a[d]);
                ans+=(b[d]-a[d]);
              }else{
                ans+=a[d+1];
                a[d+1]=0;
              }
            }else{
            	ans+=b[d];
            }
        }
    
 	

    	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 c=0;c<n+1;c++){
    		a[c]=sc.nextInt();
    	}
  		for(int c=0;c<n;c++){
        	b[c]=sc.nextInt();
        }
  		
  		long ans=0;
  		for(int d=0;d<n;d++){
        	if(a[d]<b[d]){
            	ans+=a[d];
              if(a[d+1]>b[d]-a[d]){
              	a[d+1]-=(b[d]-a[d]);
                ans+=(b[d]-a[d]);
              }else{
                ans+=a[d+1];
                a[d+1]=0;
              }
            }else{
            	ans+=b[d];
            }
        }
    
 	

    	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 c=0;c<n+1;c++){
    		a[c]=sc.nextInt();
    	}
  		for(int c=0;c<n;c++){
        	b[c]=sc.nextInt();
        }
  		
  		long ans=0;
  		for(int d=0;d<n;d++){
        	if(a[d]<b[d]){
            	ans+=a[d];
              if(a[d+1]>b[d]-a[d]){
              	a[d+1]-=(b[d]-a[d]);
                ans+=(b[d]-a[d]);
              }else{
                ans+=a[d+1];
                a[d+1]=0;
              }
            }else{
            	ans+=b[d];
            }
        }
    
 	

    	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 c=0;c<n+1;c++){
    		a[c]=sc.nextInt();
    	} int c=0; int c=0; c 0 c<n+1 c n+1 n 1 c++ c++ c {
    		a[c]=sc.nextInt();
    	} {
    		a[c]=sc.nextInt();
    	} a[c]=sc.nextInt() a[c] a c sc.nextInt() sc.nextInt sc for(int c=0;c<n;c++){
        	b[c]=sc.nextInt();
        } int c=0; int c=0; c 0 c<n c n c++ c++ c {
        	b[c]=sc.nextInt();
        } {
        	b[c]=sc.nextInt();
        } b[c]=sc.nextInt() b[c] b c sc.nextInt() sc.nextInt sc long ans=0; ans 0 for(int d=0;d<n;d++){
        	if(a[d]<b[d]){
            	ans+=a[d];
              if(a[d+1]>b[d]-a[d]){
              	a[d+1]-=(b[d]-a[d]);
                ans+=(b[d]-a[d]);
              }else{
                ans+=a[d+1];
                a[d+1]=0;
              }
            }else{
            	ans+=b[d];
            }
        } int d=0; int d=0; d 0 d<n d n d++ d++ d {
        	if(a[d]<b[d]){
            	ans+=a[d];
              if(a[d+1]>b[d]-a[d]){
              	a[d+1]-=(b[d]-a[d]);
                ans+=(b[d]-a[d]);
              }else{
                ans+=a[d+1];
                a[d+1]=0;
              }
            }else{
            	ans+=b[d];
            }
        } {
        	if(a[d]<b[d]){
            	ans+=a[d];
              if(a[d+1]>b[d]-a[d]){
              	a[d+1]-=(b[d]-a[d]);
                ans+=(b[d]-a[d]);
              }else{
                ans+=a[d+1];
                a[d+1]=0;
              }
            }else{
            	ans+=b[d];
            }
        } if(a[d]<b[d]){
            	ans+=a[d];
              if(a[d+1]>b[d]-a[d]){
              	a[d+1]-=(b[d]-a[d]);
                ans+=(b[d]-a[d]);
              }else{
                ans+=a[d+1];
                a[d+1]=0;
              }
            }else{
            	ans+=b[d];
            } a[d]<b[d] a[d] a d b[d] b d {
            	ans+=a[d];
              if(a[d+1]>b[d]-a[d]){
              	a[d+1]-=(b[d]-a[d]);
                ans+=(b[d]-a[d]);
              }else{
                ans+=a[d+1];
                a[d+1]=0;
              }
            } ans+=a[d] ans a[d] a d if(a[d+1]>b[d]-a[d]){
              	a[d+1]-=(b[d]-a[d]);
                ans+=(b[d]-a[d]);
              }else{
                ans+=a[d+1];
                a[d+1]=0;
              } a[d+1]>b[d]-a[d] a[d+1] a d+1 d 1 b[d]-a[d] b[d] b d a[d] a d {
              	a[d+1]-=(b[d]-a[d]);
                ans+=(b[d]-a[d]);
              } a[d+1]-=(b[d]-a[d]) a[d+1] a d+1 d 1 (b[d]-a[d]) b[d] b d a[d] a d ans+=(b[d]-a[d]) ans (b[d]-a[d]) b[d] b d a[d] a d {
                ans+=a[d+1];
                a[d+1]=0;
              } ans+=a[d+1] ans a[d+1] a d+1 d 1 a[d+1]=0 a[d+1] a d+1 d 1 0 {
            	ans+=b[d];
            } ans+=b[d] ans b[d] b d System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*; 

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 c=0;c<n+1;c++){
    		a[c]=sc.nextInt();
    	}
  		for(int c=0;c<n;c++){
        	b[c]=sc.nextInt();
        }
  		
  		long ans=0;
  		for(int d=0;d<n;d++){
        	if(a[d]<b[d]){
            	ans+=a[d];
              if(a[d+1]>b[d]-a[d]){
              	a[d+1]-=(b[d]-a[d]);
                ans+=(b[d]-a[d]);
              }else{
                ans+=a[d+1];
                a[d+1]=0;
              }
            }else{
            	ans+=b[d];
            }
        }
    
 	

    	System.out.println(ans);
    }
}

