 
 
import java.util.Scanner;
 
 
  class Main {
    public static void main(String[]args){
        Scanner scan = new Scanner(System.in);
         int n = scan.nextInt();
        
        long[] arr = new long[n+1];
        long[] arr2 = new long[n];
        
        for(int i = 0 ; i<n+1 ; i++){
            arr[i] = scan.nextInt();
        }
        for(int i = 0 ; i < n ;i++){
            arr2[i] = scan.nextInt();
        }
        long count = 0 ;
        for(int i = 0 ; i< n ;i++){
            long a = Math.min(arr[i],arr2[i]);
            if(a == arr[i]){
                count +=a ;
                long b = Math.max(arr[i],arr2[i]) - Math.min(arr[i],arr2[i]);
                if(arr[i+1] > b){
                    count+=b;
                    arr[i+1] = arr[i+1] - b ;
                }else{
                    count+=arr[i+1]; 
                    arr[i+1] = 0 ;
                }
            }else{
                count +=a ;
            }
        }
        System.out.println(count);
    }
} import java.util.Scanner; Scanner java.util class Main {
    public static void main(String[]args){
        Scanner scan = new Scanner(System.in);
         int n = scan.nextInt();
        
        long[] arr = new long[n+1];
        long[] arr2 = new long[n];
        
        for(int i = 0 ; i<n+1 ; i++){
            arr[i] = scan.nextInt();
        }
        for(int i = 0 ; i < n ;i++){
            arr2[i] = scan.nextInt();
        }
        long count = 0 ;
        for(int i = 0 ; i< n ;i++){
            long a = Math.min(arr[i],arr2[i]);
            if(a == arr[i]){
                count +=a ;
                long b = Math.max(arr[i],arr2[i]) - Math.min(arr[i],arr2[i]);
                if(arr[i+1] > b){
                    count+=b;
                    arr[i+1] = arr[i+1] - b ;
                }else{
                    count+=arr[i+1]; 
                    arr[i+1] = 0 ;
                }
            }else{
                count +=a ;
            }
        }
        System.out.println(count);
    }
} Main public static void main(String[]args){
        Scanner scan = new Scanner(System.in);
         int n = scan.nextInt();
        
        long[] arr = new long[n+1];
        long[] arr2 = new long[n];
        
        for(int i = 0 ; i<n+1 ; i++){
            arr[i] = scan.nextInt();
        }
        for(int i = 0 ; i < n ;i++){
            arr2[i] = scan.nextInt();
        }
        long count = 0 ;
        for(int i = 0 ; i< n ;i++){
            long a = Math.min(arr[i],arr2[i]);
            if(a == arr[i]){
                count +=a ;
                long b = Math.max(arr[i],arr2[i]) - Math.min(arr[i],arr2[i]);
                if(arr[i+1] > b){
                    count+=b;
                    arr[i+1] = arr[i+1] - b ;
                }else{
                    count+=arr[i+1]; 
                    arr[i+1] = 0 ;
                }
            }else{
                count +=a ;
            }
        }
        System.out.println(count);
    } main {
        Scanner scan = new Scanner(System.in);
         int n = scan.nextInt();
        
        long[] arr = new long[n+1];
        long[] arr2 = new long[n];
        
        for(int i = 0 ; i<n+1 ; i++){
            arr[i] = scan.nextInt();
        }
        for(int i = 0 ; i < n ;i++){
            arr2[i] = scan.nextInt();
        }
        long count = 0 ;
        for(int i = 0 ; i< n ;i++){
            long a = Math.min(arr[i],arr2[i]);
            if(a == arr[i]){
                count +=a ;
                long b = Math.max(arr[i],arr2[i]) - Math.min(arr[i],arr2[i]);
                if(arr[i+1] > b){
                    count+=b;
                    arr[i+1] = arr[i+1] - b ;
                }else{
                    count+=arr[i+1]; 
                    arr[i+1] = 0 ;
                }
            }else{
                count +=a ;
            }
        }
        System.out.println(count);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan long[] arr = new long[n+1]; arr new long[n+1] n+1 n 1 long[] arr2 = new long[n]; arr2 new long[n] n for(int i = 0 ; i<n+1 ; i++){
            arr[i] = scan.nextInt();
        } int i = 0 ; int i = 0 ; i 0 i<n+1 i n+1 n 1 i++ i++ i {
            arr[i] = scan.nextInt();
        } {
            arr[i] = scan.nextInt();
        } arr[i] = scan.nextInt() arr[i] arr i scan.nextInt() scan.nextInt scan for(int i = 0 ; i < n ;i++){
            arr2[i] = scan.nextInt();
        } int i = 0 ; int i = 0 ; i 0 i < n i n i++ i++ i {
            arr2[i] = scan.nextInt();
        } {
            arr2[i] = scan.nextInt();
        } arr2[i] = scan.nextInt() arr2[i] arr2 i scan.nextInt() scan.nextInt scan long count = 0 ; count 0 for(int i = 0 ; i< n ;i++){
            long a = Math.min(arr[i],arr2[i]);
            if(a == arr[i]){
                count +=a ;
                long b = Math.max(arr[i],arr2[i]) - Math.min(arr[i],arr2[i]);
                if(arr[i+1] > b){
                    count+=b;
                    arr[i+1] = arr[i+1] - b ;
                }else{
                    count+=arr[i+1]; 
                    arr[i+1] = 0 ;
                }
            }else{
                count +=a ;
            }
        } int i = 0 ; int i = 0 ; i 0 i< n i n i++ i++ i {
            long a = Math.min(arr[i],arr2[i]);
            if(a == arr[i]){
                count +=a ;
                long b = Math.max(arr[i],arr2[i]) - Math.min(arr[i],arr2[i]);
                if(arr[i+1] > b){
                    count+=b;
                    arr[i+1] = arr[i+1] - b ;
                }else{
                    count+=arr[i+1]; 
                    arr[i+1] = 0 ;
                }
            }else{
                count +=a ;
            }
        } {
            long a = Math.min(arr[i],arr2[i]);
            if(a == arr[i]){
                count +=a ;
                long b = Math.max(arr[i],arr2[i]) - Math.min(arr[i],arr2[i]);
                if(arr[i+1] > b){
                    count+=b;
                    arr[i+1] = arr[i+1] - b ;
                }else{
                    count+=arr[i+1]; 
                    arr[i+1] = 0 ;
                }
            }else{
                count +=a ;
            }
        } long a = Math.min(arr[i],arr2[i]); a Math.min(arr[i],arr2[i]) Math.min Math arr[i] arr i arr2[i] arr2 i if(a == arr[i]){
                count +=a ;
                long b = Math.max(arr[i],arr2[i]) - Math.min(arr[i],arr2[i]);
                if(arr[i+1] > b){
                    count+=b;
                    arr[i+1] = arr[i+1] - b ;
                }else{
                    count+=arr[i+1]; 
                    arr[i+1] = 0 ;
                }
            }else{
                count +=a ;
            } a == arr[i] a arr[i] arr i {
                count +=a ;
                long b = Math.max(arr[i],arr2[i]) - Math.min(arr[i],arr2[i]);
                if(arr[i+1] > b){
                    count+=b;
                    arr[i+1] = arr[i+1] - b ;
                }else{
                    count+=arr[i+1]; 
                    arr[i+1] = 0 ;
                }
            } count +=a count a long b = Math.max(arr[i],arr2[i]) - Math.min(arr[i],arr2[i]); b Math.max(arr[i],arr2[i]) - Math.min(arr[i],arr2[i]) Math.max(arr[i],arr2[i]) Math.max Math arr[i] arr i arr2[i] arr2 i Math.min(arr[i],arr2[i]) Math.min Math arr[i] arr i arr2[i] arr2 i if(arr[i+1] > b){
                    count+=b;
                    arr[i+1] = arr[i+1] - b ;
                }else{
                    count+=arr[i+1]; 
                    arr[i+1] = 0 ;
                } arr[i+1] > b arr[i+1] arr i+1 i 1 b {
                    count+=b;
                    arr[i+1] = arr[i+1] - b ;
                } count+=b count b arr[i+1] = arr[i+1] - b arr[i+1] arr i+1 i 1 arr[i+1] - b arr[i+1] arr i+1 i 1 b {
                    count+=arr[i+1]; 
                    arr[i+1] = 0 ;
                } count+=arr[i+1] count arr[i+1] arr i+1 i 1 arr[i+1] = 0 arr[i+1] arr i+1 i 1 0 {
                count +=a ;
            } count +=a count a 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 scan = new Scanner(System.in);
         int n = scan.nextInt();
        
        long[] arr = new long[n+1];
        long[] arr2 = new long[n];
        
        for(int i = 0 ; i<n+1 ; i++){
            arr[i] = scan.nextInt();
        }
        for(int i = 0 ; i < n ;i++){
            arr2[i] = scan.nextInt();
        }
        long count = 0 ;
        for(int i = 0 ; i< n ;i++){
            long a = Math.min(arr[i],arr2[i]);
            if(a == arr[i]){
                count +=a ;
                long b = Math.max(arr[i],arr2[i]) - Math.min(arr[i],arr2[i]);
                if(arr[i+1] > b){
                    count+=b;
                    arr[i+1] = arr[i+1] - b ;
                }else{
                    count+=arr[i+1]; 
                    arr[i+1] = 0 ;
                }
            }else{
                count +=a ;
            }
        }
        System.out.println(count);
    }
}
