import java.util.*;
 
public class Main{
 
    
 
        
    
 
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] ms = new long[n+1];
        long[] hs = new long[n];
 
        for(int i=0;i<n+1;i++){
            ms[i] = sc.nextLong();
        }
        
        for(int i=0;i<n;i++){
            hs[i] = sc.nextLong();
        }
 
        long tot = 0;
        long min;
 
        for(int i = n;i>=0;i--){
            
            if(i<=n-1){
                min = Math.min(ms[i],hs[i]);
                ms[i] -= min;
                hs[i] -= min;
                tot += min;
            }
            
 
            if(i > 0){
                min = Math.min(ms[i],hs[i-1]);
                ms[i] -= min;
                hs[i-1] -= min;
                tot += min;
            }
            
        }
 
      
        System.out.println(tot);
 
 
 
        sc.close();
    }
} import java.util.*; util.* java public class Main{
 
    
 
        
    
 
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] ms = new long[n+1];
        long[] hs = new long[n];
 
        for(int i=0;i<n+1;i++){
            ms[i] = sc.nextLong();
        }
        
        for(int i=0;i<n;i++){
            hs[i] = sc.nextLong();
        }
 
        long tot = 0;
        long min;
 
        for(int i = n;i>=0;i--){
            
            if(i<=n-1){
                min = Math.min(ms[i],hs[i]);
                ms[i] -= min;
                hs[i] -= min;
                tot += min;
            }
            
 
            if(i > 0){
                min = Math.min(ms[i],hs[i-1]);
                ms[i] -= min;
                hs[i-1] -= min;
                tot += min;
            }
            
        }
 
      
        System.out.println(tot);
 
 
 
        sc.close();
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] ms = new long[n+1];
        long[] hs = new long[n];
 
        for(int i=0;i<n+1;i++){
            ms[i] = sc.nextLong();
        }
        
        for(int i=0;i<n;i++){
            hs[i] = sc.nextLong();
        }
 
        long tot = 0;
        long min;
 
        for(int i = n;i>=0;i--){
            
            if(i<=n-1){
                min = Math.min(ms[i],hs[i]);
                ms[i] -= min;
                hs[i] -= min;
                tot += min;
            }
            
 
            if(i > 0){
                min = Math.min(ms[i],hs[i-1]);
                ms[i] -= min;
                hs[i-1] -= min;
                tot += min;
            }
            
        }
 
      
        System.out.println(tot);
 
 
 
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] ms = new long[n+1];
        long[] hs = new long[n];
 
        for(int i=0;i<n+1;i++){
            ms[i] = sc.nextLong();
        }
        
        for(int i=0;i<n;i++){
            hs[i] = sc.nextLong();
        }
 
        long tot = 0;
        long min;
 
        for(int i = n;i>=0;i--){
            
            if(i<=n-1){
                min = Math.min(ms[i],hs[i]);
                ms[i] -= min;
                hs[i] -= min;
                tot += min;
            }
            
 
            if(i > 0){
                min = Math.min(ms[i],hs[i-1]);
                ms[i] -= min;
                hs[i-1] -= min;
                tot += min;
            }
            
        }
 
      
        System.out.println(tot);
 
 
 
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc long[] ms = new long[n+1]; ms new long[n+1] n+1 n 1 long[] hs = new long[n]; hs new long[n] n for(int i=0;i<n+1;i++){
            ms[i] = sc.nextLong();
        } int i=0; int i=0; i 0 i<n+1 i n+1 n 1 i++ i++ i {
            ms[i] = sc.nextLong();
        } {
            ms[i] = sc.nextLong();
        } ms[i] = sc.nextLong() ms[i] ms i sc.nextLong() sc.nextLong sc for(int i=0;i<n;i++){
            hs[i] = sc.nextLong();
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            hs[i] = sc.nextLong();
        } {
            hs[i] = sc.nextLong();
        } hs[i] = sc.nextLong() hs[i] hs i sc.nextLong() sc.nextLong sc long tot = 0; tot 0 long min; min for(int i = n;i>=0;i--){
            
            if(i<=n-1){
                min = Math.min(ms[i],hs[i]);
                ms[i] -= min;
                hs[i] -= min;
                tot += min;
            }
            
 
            if(i > 0){
                min = Math.min(ms[i],hs[i-1]);
                ms[i] -= min;
                hs[i-1] -= min;
                tot += min;
            }
            
        } int i = n; int i = n; i n i>=0 i 0 i-- i-- i {
            
            if(i<=n-1){
                min = Math.min(ms[i],hs[i]);
                ms[i] -= min;
                hs[i] -= min;
                tot += min;
            }
            
 
            if(i > 0){
                min = Math.min(ms[i],hs[i-1]);
                ms[i] -= min;
                hs[i-1] -= min;
                tot += min;
            }
            
        } {
            
            if(i<=n-1){
                min = Math.min(ms[i],hs[i]);
                ms[i] -= min;
                hs[i] -= min;
                tot += min;
            }
            
 
            if(i > 0){
                min = Math.min(ms[i],hs[i-1]);
                ms[i] -= min;
                hs[i-1] -= min;
                tot += min;
            }
            
        } if(i<=n-1){
                min = Math.min(ms[i],hs[i]);
                ms[i] -= min;
                hs[i] -= min;
                tot += min;
            } i<=n-1 i n-1 n 1 {
                min = Math.min(ms[i],hs[i]);
                ms[i] -= min;
                hs[i] -= min;
                tot += min;
            } min = Math.min(ms[i],hs[i]) min Math.min(ms[i],hs[i]) Math.min Math ms[i] ms i hs[i] hs i ms[i] -= min ms[i] ms i min hs[i] -= min hs[i] hs i min tot += min tot min if(i > 0){
                min = Math.min(ms[i],hs[i-1]);
                ms[i] -= min;
                hs[i-1] -= min;
                tot += min;
            } i > 0 i 0 {
                min = Math.min(ms[i],hs[i-1]);
                ms[i] -= min;
                hs[i-1] -= min;
                tot += min;
            } min = Math.min(ms[i],hs[i-1]) min Math.min(ms[i],hs[i-1]) Math.min Math ms[i] ms i hs[i-1] hs i-1 i 1 ms[i] -= min ms[i] ms i min hs[i-1] -= min hs[i-1] hs i-1 i 1 min tot += min tot min System.out.println(tot) System.out.println System.out System System.out tot sc.close() sc.close sc String[] args args public class Main{
 
    
 
        
    
 
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] ms = new long[n+1];
        long[] hs = new long[n];
 
        for(int i=0;i<n+1;i++){
            ms[i] = sc.nextLong();
        }
        
        for(int i=0;i<n;i++){
            hs[i] = sc.nextLong();
        }
 
        long tot = 0;
        long min;
 
        for(int i = n;i>=0;i--){
            
            if(i<=n-1){
                min = Math.min(ms[i],hs[i]);
                ms[i] -= min;
                hs[i] -= min;
                tot += min;
            }
            
 
            if(i > 0){
                min = Math.min(ms[i],hs[i-1]);
                ms[i] -= min;
                hs[i-1] -= min;
                tot += min;
            }
            
        }
 
      
        System.out.println(tot);
 
 
 
        sc.close();
    }
} public class Main{
 
    
 
        
    
 
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] ms = new long[n+1];
        long[] hs = new long[n];
 
        for(int i=0;i<n+1;i++){
            ms[i] = sc.nextLong();
        }
        
        for(int i=0;i<n;i++){
            hs[i] = sc.nextLong();
        }
 
        long tot = 0;
        long min;
 
        for(int i = n;i>=0;i--){
            
            if(i<=n-1){
                min = Math.min(ms[i],hs[i]);
                ms[i] -= min;
                hs[i] -= min;
                tot += min;
            }
            
 
            if(i > 0){
                min = Math.min(ms[i],hs[i-1]);
                ms[i] -= min;
                hs[i-1] -= min;
                tot += min;
            }
            
        }
 
      
        System.out.println(tot);
 
 
 
        sc.close();
    }
} Main
import java.util.*;
 
public class Main{
 
    
 
        
    
 
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] ms = new long[n+1];
        long[] hs = new long[n];
 
        for(int i=0;i<n+1;i++){
            ms[i] = sc.nextLong();
        }
        
        for(int i=0;i<n;i++){
            hs[i] = sc.nextLong();
        }
 
        long tot = 0;
        long min;
 
        for(int i = n;i>=0;i--){
            
            if(i<=n-1){
                min = Math.min(ms[i],hs[i]);
                ms[i] -= min;
                hs[i] -= min;
                tot += min;
            }
            
 
            if(i > 0){
                min = Math.min(ms[i],hs[i-1]);
                ms[i] -= min;
                hs[i-1] -= min;
                tot += min;
            }
            
        }
 
      
        System.out.println(tot);
 
 
 
        sc.close();
    }
}