
import java.util.*;







// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail

public class Main{
    public static void main(String args[] ) throws Exception {
        
        //Scanner
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long[] A = new long[n+1];
        long[] B = new long[n];
        for(int i=0;i<n+1;i++) {
            A[i] = scanner.nextLong();
            
        }
        for(int i=0;i<n;i++) {
            B[i] = scanner.nextLong();
        }
        long sum=0;
        for(int i=0;i<n;i++) {
            if(A[i]>B[i]) {
                A[i]-=B[i];
                sum+=B[i];
                B[i] = 0;
            }
            else {
                sum+=A[i];
                B[i]-=A[i];
                A[i]=0;
            }
            
            
            if(A[i+1]>B[i]) {
                A[i+1]-=B[i];
                sum+=B[i];
                B[i] = 0;
            }
            else {
                sum+=A[i+1];
                B[i]-=A[i+1];
                A[i+1]=0;
            }
        }
        System.out.println(sum);
    }
    
    
    
} import java.util.*; util.* java public class Main{
    public static void main(String args[] ) throws Exception {
        
        //Scanner
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long[] A = new long[n+1];
        long[] B = new long[n];
        for(int i=0;i<n+1;i++) {
            A[i] = scanner.nextLong();
            
        }
        for(int i=0;i<n;i++) {
            B[i] = scanner.nextLong();
        }
        long sum=0;
        for(int i=0;i<n;i++) {
            if(A[i]>B[i]) {
                A[i]-=B[i];
                sum+=B[i];
                B[i] = 0;
            }
            else {
                sum+=A[i];
                B[i]-=A[i];
                A[i]=0;
            }
            
            
            if(A[i+1]>B[i]) {
                A[i+1]-=B[i];
                sum+=B[i];
                B[i] = 0;
            }
            else {
                sum+=A[i+1];
                B[i]-=A[i+1];
                A[i+1]=0;
            }
        }
        System.out.println(sum);
    }
    
    
    
} Main public static void main(String args[] ) throws Exception {
        
        //Scanner
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long[] A = new long[n+1];
        long[] B = new long[n];
        for(int i=0;i<n+1;i++) {
            A[i] = scanner.nextLong();
            
        }
        for(int i=0;i<n;i++) {
            B[i] = scanner.nextLong();
        }
        long sum=0;
        for(int i=0;i<n;i++) {
            if(A[i]>B[i]) {
                A[i]-=B[i];
                sum+=B[i];
                B[i] = 0;
            }
            else {
                sum+=A[i];
                B[i]-=A[i];
                A[i]=0;
            }
            
            
            if(A[i+1]>B[i]) {
                A[i+1]-=B[i];
                sum+=B[i];
                B[i] = 0;
            }
            else {
                sum+=A[i+1];
                B[i]-=A[i+1];
                A[i+1]=0;
            }
        }
        System.out.println(sum);
    } main {
        
        //Scanner
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long[] A = new long[n+1];
        long[] B = new long[n];
        for(int i=0;i<n+1;i++) {
            A[i] = scanner.nextLong();
            
        }
        for(int i=0;i<n;i++) {
            B[i] = scanner.nextLong();
        }
        long sum=0;
        for(int i=0;i<n;i++) {
            if(A[i]>B[i]) {
                A[i]-=B[i];
                sum+=B[i];
                B[i] = 0;
            }
            else {
                sum+=A[i];
                B[i]-=A[i];
                A[i]=0;
            }
            
            
            if(A[i+1]>B[i]) {
                A[i+1]-=B[i];
                sum+=B[i];
                B[i] = 0;
            }
            else {
                sum+=A[i+1];
                B[i]-=A[i+1];
                A[i+1]=0;
            }
        }
        System.out.println(sum);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner 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] = scanner.nextLong();
            
        } int i=0; int i=0; i 0 i<n+1 i n+1 n 1 i++ i++ i {
            A[i] = scanner.nextLong();
            
        } {
            A[i] = scanner.nextLong();
            
        } A[i] = scanner.nextLong() A[i] A i scanner.nextLong() scanner.nextLong scanner for(int i=0;i<n;i++) {
            B[i] = scanner.nextLong();
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            B[i] = scanner.nextLong();
        } {
            B[i] = scanner.nextLong();
        } B[i] = scanner.nextLong() B[i] B i scanner.nextLong() scanner.nextLong scanner long sum=0; sum 0 for(int i=0;i<n;i++) {
            if(A[i]>B[i]) {
                A[i]-=B[i];
                sum+=B[i];
                B[i] = 0;
            }
            else {
                sum+=A[i];
                B[i]-=A[i];
                A[i]=0;
            }
            
            
            if(A[i+1]>B[i]) {
                A[i+1]-=B[i];
                sum+=B[i];
                B[i] = 0;
            }
            else {
                sum+=A[i+1];
                B[i]-=A[i+1];
                A[i+1]=0;
            }
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            if(A[i]>B[i]) {
                A[i]-=B[i];
                sum+=B[i];
                B[i] = 0;
            }
            else {
                sum+=A[i];
                B[i]-=A[i];
                A[i]=0;
            }
            
            
            if(A[i+1]>B[i]) {
                A[i+1]-=B[i];
                sum+=B[i];
                B[i] = 0;
            }
            else {
                sum+=A[i+1];
                B[i]-=A[i+1];
                A[i+1]=0;
            }
        } {
            if(A[i]>B[i]) {
                A[i]-=B[i];
                sum+=B[i];
                B[i] = 0;
            }
            else {
                sum+=A[i];
                B[i]-=A[i];
                A[i]=0;
            }
            
            
            if(A[i+1]>B[i]) {
                A[i+1]-=B[i];
                sum+=B[i];
                B[i] = 0;
            }
            else {
                sum+=A[i+1];
                B[i]-=A[i+1];
                A[i+1]=0;
            }
        } if(A[i]>B[i]) {
                A[i]-=B[i];
                sum+=B[i];
                B[i] = 0;
            }
            else {
                sum+=A[i];
                B[i]-=A[i];
                A[i]=0;
            } A[i]>B[i] A[i] A i B[i] B i {
                A[i]-=B[i];
                sum+=B[i];
                B[i] = 0;
            } A[i]-=B[i] A[i] A i B[i] B i sum+=B[i] sum B[i] B i B[i] = 0 B[i] B i 0 {
                sum+=A[i];
                B[i]-=A[i];
                A[i]=0;
            } sum+=A[i] sum A[i] A i B[i]-=A[i] B[i] B i A[i] A i A[i]=0 A[i] A i 0 if(A[i+1]>B[i]) {
                A[i+1]-=B[i];
                sum+=B[i];
                B[i] = 0;
            }
            else {
                sum+=A[i+1];
                B[i]-=A[i+1];
                A[i+1]=0;
            } A[i+1]>B[i] A[i+1] A i+1 i 1 B[i] B i {
                A[i+1]-=B[i];
                sum+=B[i];
                B[i] = 0;
            } A[i+1]-=B[i] A[i+1] A i+1 i 1 B[i] B i sum+=B[i] sum B[i] B i B[i] = 0 B[i] B i 0 {
                sum+=A[i+1];
                B[i]-=A[i+1];
                A[i+1]=0;
            } sum+=A[i+1] sum A[i+1] A i+1 i 1 B[i]-=A[i+1] B[i] B i A[i+1] A i+1 i 1 A[i+1]=0 A[i+1] A i+1 i 1 0 System.out.println(sum) System.out.println System.out System System.out sum String args[] args public class Main{
    public static void main(String args[] ) throws Exception {
        
        //Scanner
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long[] A = new long[n+1];
        long[] B = new long[n];
        for(int i=0;i<n+1;i++) {
            A[i] = scanner.nextLong();
            
        }
        for(int i=0;i<n;i++) {
            B[i] = scanner.nextLong();
        }
        long sum=0;
        for(int i=0;i<n;i++) {
            if(A[i]>B[i]) {
                A[i]-=B[i];
                sum+=B[i];
                B[i] = 0;
            }
            else {
                sum+=A[i];
                B[i]-=A[i];
                A[i]=0;
            }
            
            
            if(A[i+1]>B[i]) {
                A[i+1]-=B[i];
                sum+=B[i];
                B[i] = 0;
            }
            else {
                sum+=A[i+1];
                B[i]-=A[i+1];
                A[i+1]=0;
            }
        }
        System.out.println(sum);
    }
    
    
    
} public class Main{
    public static void main(String args[] ) throws Exception {
        
        //Scanner
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long[] A = new long[n+1];
        long[] B = new long[n];
        for(int i=0;i<n+1;i++) {
            A[i] = scanner.nextLong();
            
        }
        for(int i=0;i<n;i++) {
            B[i] = scanner.nextLong();
        }
        long sum=0;
        for(int i=0;i<n;i++) {
            if(A[i]>B[i]) {
                A[i]-=B[i];
                sum+=B[i];
                B[i] = 0;
            }
            else {
                sum+=A[i];
                B[i]-=A[i];
                A[i]=0;
            }
            
            
            if(A[i+1]>B[i]) {
                A[i+1]-=B[i];
                sum+=B[i];
                B[i] = 0;
            }
            else {
                sum+=A[i+1];
                B[i]-=A[i+1];
                A[i+1]=0;
            }
        }
        System.out.println(sum);
    }
    
    
    
} Main

import java.util.*;







// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail

public class Main{
    public static void main(String args[] ) throws Exception {
        
        //Scanner
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long[] A = new long[n+1];
        long[] B = new long[n];
        for(int i=0;i<n+1;i++) {
            A[i] = scanner.nextLong();
            
        }
        for(int i=0;i<n;i++) {
            B[i] = scanner.nextLong();
        }
        long sum=0;
        for(int i=0;i<n;i++) {
            if(A[i]>B[i]) {
                A[i]-=B[i];
                sum+=B[i];
                B[i] = 0;
            }
            else {
                sum+=A[i];
                B[i]-=A[i];
                A[i]=0;
            }
            
            
            if(A[i+1]>B[i]) {
                A[i+1]-=B[i];
                sum+=B[i];
                B[i] = 0;
            }
            else {
                sum+=A[i+1];
                B[i]-=A[i+1];
                A[i+1]=0;
            }
        }
        System.out.println(sum);
    }
    
    
    
}
