import java.util.*;

public class Main{

    public static void main(String args[]){

        Scanner scan = new Scanner(System.in);
        Integer N = Integer.parseInt(scan.next());
        Long A[] = new Long[N+1];
        Long B[] = new Long[N];

        for(int i=0;i<N+1;i++){
            A[i] = Long.parseLong(scan.next());
        }
        for(int i=0;i<N;i++){
            B[i] = Long.parseLong(scan.next());
        }

        long counter = 0;
        for(int i=0;i<N;i++){
            if(A[i] <= B[i]){
                counter += A[i];
                B[i] -= A[i];
                A[i] = 0L;                
            }else{
                counter += B[i];
                A[i] -= B[i];
                B[i] = 0L;
            }

            if(B[i] != 0L){
                if(A[i+1] <= B[i]){
                    counter += A[i+1];
                    B[i] -= A[i+1];
                    A[i+1] = 0L;                
                }else{
                    counter += B[i];
                    A[i+1] -= B[i];
                    B[i] = 0L;
                }
            }
        }
        
        System.out.println(counter);
    }
} import java.util.*; util.* java public class Main{

    public static void main(String args[]){

        Scanner scan = new Scanner(System.in);
        Integer N = Integer.parseInt(scan.next());
        Long A[] = new Long[N+1];
        Long B[] = new Long[N];

        for(int i=0;i<N+1;i++){
            A[i] = Long.parseLong(scan.next());
        }
        for(int i=0;i<N;i++){
            B[i] = Long.parseLong(scan.next());
        }

        long counter = 0;
        for(int i=0;i<N;i++){
            if(A[i] <= B[i]){
                counter += A[i];
                B[i] -= A[i];
                A[i] = 0L;                
            }else{
                counter += B[i];
                A[i] -= B[i];
                B[i] = 0L;
            }

            if(B[i] != 0L){
                if(A[i+1] <= B[i]){
                    counter += A[i+1];
                    B[i] -= A[i+1];
                    A[i+1] = 0L;                
                }else{
                    counter += B[i];
                    A[i+1] -= B[i];
                    B[i] = 0L;
                }
            }
        }
        
        System.out.println(counter);
    }
} Main public static void main(String args[]){

        Scanner scan = new Scanner(System.in);
        Integer N = Integer.parseInt(scan.next());
        Long A[] = new Long[N+1];
        Long B[] = new Long[N];

        for(int i=0;i<N+1;i++){
            A[i] = Long.parseLong(scan.next());
        }
        for(int i=0;i<N;i++){
            B[i] = Long.parseLong(scan.next());
        }

        long counter = 0;
        for(int i=0;i<N;i++){
            if(A[i] <= B[i]){
                counter += A[i];
                B[i] -= A[i];
                A[i] = 0L;                
            }else{
                counter += B[i];
                A[i] -= B[i];
                B[i] = 0L;
            }

            if(B[i] != 0L){
                if(A[i+1] <= B[i]){
                    counter += A[i+1];
                    B[i] -= A[i+1];
                    A[i+1] = 0L;                
                }else{
                    counter += B[i];
                    A[i+1] -= B[i];
                    B[i] = 0L;
                }
            }
        }
        
        System.out.println(counter);
    } main {

        Scanner scan = new Scanner(System.in);
        Integer N = Integer.parseInt(scan.next());
        Long A[] = new Long[N+1];
        Long B[] = new Long[N];

        for(int i=0;i<N+1;i++){
            A[i] = Long.parseLong(scan.next());
        }
        for(int i=0;i<N;i++){
            B[i] = Long.parseLong(scan.next());
        }

        long counter = 0;
        for(int i=0;i<N;i++){
            if(A[i] <= B[i]){
                counter += A[i];
                B[i] -= A[i];
                A[i] = 0L;                
            }else{
                counter += B[i];
                A[i] -= B[i];
                B[i] = 0L;
            }

            if(B[i] != 0L){
                if(A[i+1] <= B[i]){
                    counter += A[i+1];
                    B[i] -= A[i+1];
                    A[i+1] = 0L;                
                }else{
                    counter += B[i];
                    A[i+1] -= B[i];
                    B[i] = 0L;
                }
            }
        }
        
        System.out.println(counter);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) Integer N = Integer.parseInt(scan.next()); N Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan 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] = Long.parseLong(scan.next());
        } int i=0; int i=0; i 0 i<N+1 i N+1 N 1 i++ i++ i {
            A[i] = Long.parseLong(scan.next());
        } {
            A[i] = Long.parseLong(scan.next());
        } A[i] = Long.parseLong(scan.next()) A[i] A i Long.parseLong(scan.next()) Long.parseLong Long scan.next() scan.next scan for(int i=0;i<N;i++){
            B[i] = Long.parseLong(scan.next());
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            B[i] = Long.parseLong(scan.next());
        } {
            B[i] = Long.parseLong(scan.next());
        } B[i] = Long.parseLong(scan.next()) B[i] B i Long.parseLong(scan.next()) Long.parseLong Long scan.next() scan.next scan long counter = 0; counter 0 for(int i=0;i<N;i++){
            if(A[i] <= B[i]){
                counter += A[i];
                B[i] -= A[i];
                A[i] = 0L;                
            }else{
                counter += B[i];
                A[i] -= B[i];
                B[i] = 0L;
            }

            if(B[i] != 0L){
                if(A[i+1] <= B[i]){
                    counter += A[i+1];
                    B[i] -= A[i+1];
                    A[i+1] = 0L;                
                }else{
                    counter += B[i];
                    A[i+1] -= B[i];
                    B[i] = 0L;
                }
            }
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            if(A[i] <= B[i]){
                counter += A[i];
                B[i] -= A[i];
                A[i] = 0L;                
            }else{
                counter += B[i];
                A[i] -= B[i];
                B[i] = 0L;
            }

            if(B[i] != 0L){
                if(A[i+1] <= B[i]){
                    counter += A[i+1];
                    B[i] -= A[i+1];
                    A[i+1] = 0L;                
                }else{
                    counter += B[i];
                    A[i+1] -= B[i];
                    B[i] = 0L;
                }
            }
        } {
            if(A[i] <= B[i]){
                counter += A[i];
                B[i] -= A[i];
                A[i] = 0L;                
            }else{
                counter += B[i];
                A[i] -= B[i];
                B[i] = 0L;
            }

            if(B[i] != 0L){
                if(A[i+1] <= B[i]){
                    counter += A[i+1];
                    B[i] -= A[i+1];
                    A[i+1] = 0L;                
                }else{
                    counter += B[i];
                    A[i+1] -= B[i];
                    B[i] = 0L;
                }
            }
        } if(A[i] <= B[i]){
                counter += A[i];
                B[i] -= A[i];
                A[i] = 0L;                
            }else{
                counter += B[i];
                A[i] -= B[i];
                B[i] = 0L;
            } A[i] <= B[i] A[i] A i B[i] B i {
                counter += A[i];
                B[i] -= A[i];
                A[i] = 0L;                
            } counter += A[i] counter A[i] A i B[i] -= A[i] B[i] B i A[i] A i A[i] = 0L A[i] A i 0L {
                counter += B[i];
                A[i] -= B[i];
                B[i] = 0L;
            } counter += B[i] counter B[i] B i A[i] -= B[i] A[i] A i B[i] B i B[i] = 0L B[i] B i 0L if(B[i] != 0L){
                if(A[i+1] <= B[i]){
                    counter += A[i+1];
                    B[i] -= A[i+1];
                    A[i+1] = 0L;                
                }else{
                    counter += B[i];
                    A[i+1] -= B[i];
                    B[i] = 0L;
                }
            } B[i] != 0L B[i] B i 0L {
                if(A[i+1] <= B[i]){
                    counter += A[i+1];
                    B[i] -= A[i+1];
                    A[i+1] = 0L;                
                }else{
                    counter += B[i];
                    A[i+1] -= B[i];
                    B[i] = 0L;
                }
            } if(A[i+1] <= B[i]){
                    counter += A[i+1];
                    B[i] -= A[i+1];
                    A[i+1] = 0L;                
                }else{
                    counter += B[i];
                    A[i+1] -= B[i];
                    B[i] = 0L;
                } A[i+1] <= B[i] A[i+1] A i+1 i 1 B[i] B i {
                    counter += A[i+1];
                    B[i] -= A[i+1];
                    A[i+1] = 0L;                
                } counter += A[i+1] counter 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] = 0L A[i+1] A i+1 i 1 0L {
                    counter += B[i];
                    A[i+1] -= B[i];
                    B[i] = 0L;
                } counter += B[i] counter B[i] B i A[i+1] -= B[i] A[i+1] A i+1 i 1 B[i] B i B[i] = 0L B[i] B i 0L System.out.println(counter) System.out.println System.out System System.out counter String args[] args public class Main{

    public static void main(String args[]){

        Scanner scan = new Scanner(System.in);
        Integer N = Integer.parseInt(scan.next());
        Long A[] = new Long[N+1];
        Long B[] = new Long[N];

        for(int i=0;i<N+1;i++){
            A[i] = Long.parseLong(scan.next());
        }
        for(int i=0;i<N;i++){
            B[i] = Long.parseLong(scan.next());
        }

        long counter = 0;
        for(int i=0;i<N;i++){
            if(A[i] <= B[i]){
                counter += A[i];
                B[i] -= A[i];
                A[i] = 0L;                
            }else{
                counter += B[i];
                A[i] -= B[i];
                B[i] = 0L;
            }

            if(B[i] != 0L){
                if(A[i+1] <= B[i]){
                    counter += A[i+1];
                    B[i] -= A[i+1];
                    A[i+1] = 0L;                
                }else{
                    counter += B[i];
                    A[i+1] -= B[i];
                    B[i] = 0L;
                }
            }
        }
        
        System.out.println(counter);
    }
} public class Main{

    public static void main(String args[]){

        Scanner scan = new Scanner(System.in);
        Integer N = Integer.parseInt(scan.next());
        Long A[] = new Long[N+1];
        Long B[] = new Long[N];

        for(int i=0;i<N+1;i++){
            A[i] = Long.parseLong(scan.next());
        }
        for(int i=0;i<N;i++){
            B[i] = Long.parseLong(scan.next());
        }

        long counter = 0;
        for(int i=0;i<N;i++){
            if(A[i] <= B[i]){
                counter += A[i];
                B[i] -= A[i];
                A[i] = 0L;                
            }else{
                counter += B[i];
                A[i] -= B[i];
                B[i] = 0L;
            }

            if(B[i] != 0L){
                if(A[i+1] <= B[i]){
                    counter += A[i+1];
                    B[i] -= A[i+1];
                    A[i+1] = 0L;                
                }else{
                    counter += B[i];
                    A[i+1] -= B[i];
                    B[i] = 0L;
                }
            }
        }
        
        System.out.println(counter);
    }
} Main
import java.util.*;

public class Main{

    public static void main(String args[]){

        Scanner scan = new Scanner(System.in);
        Integer N = Integer.parseInt(scan.next());
        Long A[] = new Long[N+1];
        Long B[] = new Long[N];

        for(int i=0;i<N+1;i++){
            A[i] = Long.parseLong(scan.next());
        }
        for(int i=0;i<N;i++){
            B[i] = Long.parseLong(scan.next());
        }

        long counter = 0;
        for(int i=0;i<N;i++){
            if(A[i] <= B[i]){
                counter += A[i];
                B[i] -= A[i];
                A[i] = 0L;                
            }else{
                counter += B[i];
                A[i] -= B[i];
                B[i] = 0L;
            }

            if(B[i] != 0L){
                if(A[i+1] <= B[i]){
                    counter += A[i+1];
                    B[i] -= A[i+1];
                    A[i+1] = 0L;                
                }else{
                    counter += B[i];
                    A[i+1] -= B[i];
                    B[i] = 0L;
                }
            }
        }
        
        System.out.println(counter);
    }
}