import java.util.*;

public class Main{
    public static void main(String[] args){
    //入力
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Long[] A = new Long[N+1];
        Long[] B = new Long[N];
        for(int i=0; i<N+1; i++){
            A[i] = sc.nextLong();
        }
        for(int i=0;i<N;i++){
            B[i] = sc.nextLong();
        }
    //処理
    Long ans = 0L;
        for(int i=0;i<N;i++){
            if(A[i]-B[i]>=0){A[i] -= B[i];ans+=B[i];}
            else{
                ans += A[i];
                B[i] -= A[i];
                A[i] = 0L;
                
                
                if(A[i+1]-B[i]>=0L){
                    A[i+1]-=B[i];
                    ans += B[i];
                }
                else if(A[i+1]-B[i]<0L){
                    ans += A[i+1];
                    A[i+1]=0L;
                }
            }
        }
        System.out.println(ans);
        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[] A = new Long[N+1];
        Long[] B = new Long[N];
        for(int i=0; i<N+1; i++){
            A[i] = sc.nextLong();
        }
        for(int i=0;i<N;i++){
            B[i] = sc.nextLong();
        }
    //処理
    Long ans = 0L;
        for(int i=0;i<N;i++){
            if(A[i]-B[i]>=0){A[i] -= B[i];ans+=B[i];}
            else{
                ans += A[i];
                B[i] -= A[i];
                A[i] = 0L;
                
                
                if(A[i+1]-B[i]>=0L){
                    A[i+1]-=B[i];
                    ans += B[i];
                }
                else if(A[i+1]-B[i]<0L){
                    ans += A[i+1];
                    A[i+1]=0L;
                }
            }
        }
        System.out.println(ans);
        sc.close();

    }
} Main public static void main(String[] args){
    //入力
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Long[] A = new Long[N+1];
        Long[] B = new Long[N];
        for(int i=0; i<N+1; i++){
            A[i] = sc.nextLong();
        }
        for(int i=0;i<N;i++){
            B[i] = sc.nextLong();
        }
    //処理
    Long ans = 0L;
        for(int i=0;i<N;i++){
            if(A[i]-B[i]>=0){A[i] -= B[i];ans+=B[i];}
            else{
                ans += A[i];
                B[i] -= A[i];
                A[i] = 0L;
                
                
                if(A[i+1]-B[i]>=0L){
                    A[i+1]-=B[i];
                    ans += B[i];
                }
                else if(A[i+1]-B[i]<0L){
                    ans += A[i+1];
                    A[i+1]=0L;
                }
            }
        }
        System.out.println(ans);
        sc.close();

    } main {
    //入力
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Long[] A = new Long[N+1];
        Long[] B = new Long[N];
        for(int i=0; i<N+1; i++){
            A[i] = sc.nextLong();
        }
        for(int i=0;i<N;i++){
            B[i] = sc.nextLong();
        }
    //処理
    Long ans = 0L;
        for(int i=0;i<N;i++){
            if(A[i]-B[i]>=0){A[i] -= B[i];ans+=B[i];}
            else{
                ans += A[i];
                B[i] -= A[i];
                A[i] = 0L;
                
                
                if(A[i+1]-B[i]>=0L){
                    A[i+1]-=B[i];
                    ans += B[i];
                }
                else if(A[i+1]-B[i]<0L){
                    ans += A[i+1];
                    A[i+1]=0L;
                }
            }
        }
        System.out.println(ans);
        sc.close();

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc 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] = sc.nextLong();
        } int i=0; int i=0; i 0 i<N+1 i N+1 N 1 i++ i++ i {
            A[i] = sc.nextLong();
        } {
            A[i] = sc.nextLong();
        } A[i] = sc.nextLong() A[i] A i sc.nextLong() sc.nextLong sc for(int i=0;i<N;i++){
            B[i] = sc.nextLong();
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            B[i] = sc.nextLong();
        } {
            B[i] = sc.nextLong();
        } B[i] = sc.nextLong() B[i] B i sc.nextLong() sc.nextLong sc Long ans = 0L; ans 0L for(int i=0;i<N;i++){
            if(A[i]-B[i]>=0){A[i] -= B[i];ans+=B[i];}
            else{
                ans += A[i];
                B[i] -= A[i];
                A[i] = 0L;
                
                
                if(A[i+1]-B[i]>=0L){
                    A[i+1]-=B[i];
                    ans += B[i];
                }
                else if(A[i+1]-B[i]<0L){
                    ans += A[i+1];
                    A[i+1]=0L;
                }
            }
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            if(A[i]-B[i]>=0){A[i] -= B[i];ans+=B[i];}
            else{
                ans += A[i];
                B[i] -= A[i];
                A[i] = 0L;
                
                
                if(A[i+1]-B[i]>=0L){
                    A[i+1]-=B[i];
                    ans += B[i];
                }
                else if(A[i+1]-B[i]<0L){
                    ans += A[i+1];
                    A[i+1]=0L;
                }
            }
        } {
            if(A[i]-B[i]>=0){A[i] -= B[i];ans+=B[i];}
            else{
                ans += A[i];
                B[i] -= A[i];
                A[i] = 0L;
                
                
                if(A[i+1]-B[i]>=0L){
                    A[i+1]-=B[i];
                    ans += B[i];
                }
                else if(A[i+1]-B[i]<0L){
                    ans += A[i+1];
                    A[i+1]=0L;
                }
            }
        } if(A[i]-B[i]>=0){A[i] -= B[i];ans+=B[i];}
            else{
                ans += A[i];
                B[i] -= A[i];
                A[i] = 0L;
                
                
                if(A[i+1]-B[i]>=0L){
                    A[i+1]-=B[i];
                    ans += B[i];
                }
                else if(A[i+1]-B[i]<0L){
                    ans += A[i+1];
                    A[i+1]=0L;
                }
            } A[i]-B[i]>=0 A[i]-B[i] A[i] A i B[i] B i 0 {A[i] -= B[i];ans+=B[i];} A[i] -= B[i] A[i] A i B[i] B i ans+=B[i] ans B[i] B i {
                ans += A[i];
                B[i] -= A[i];
                A[i] = 0L;
                
                
                if(A[i+1]-B[i]>=0L){
                    A[i+1]-=B[i];
                    ans += B[i];
                }
                else if(A[i+1]-B[i]<0L){
                    ans += A[i+1];
                    A[i+1]=0L;
                }
            } ans += A[i] ans A[i] A i B[i] -= A[i] B[i] B i A[i] A i A[i] = 0L A[i] A i 0L if(A[i+1]-B[i]>=0L){
                    A[i+1]-=B[i];
                    ans += B[i];
                }
                else if(A[i+1]-B[i]<0L){
                    ans += A[i+1];
                    A[i+1]=0L;
                } A[i+1]-B[i]>=0L A[i+1]-B[i] A[i+1] A i+1 i 1 B[i] B i 0L {
                    A[i+1]-=B[i];
                    ans += B[i];
                } A[i+1]-=B[i] A[i+1] A i+1 i 1 B[i] B i ans += B[i] ans B[i] B i if(A[i+1]-B[i]<0L){
                    ans += A[i+1];
                    A[i+1]=0L;
                } A[i+1]-B[i]<0L A[i+1]-B[i] A[i+1] A i+1 i 1 B[i] B i 0L {
                    ans += A[i+1];
                    A[i+1]=0L;
                } ans += A[i+1] ans A[i+1] A i+1 i 1 A[i+1]=0L A[i+1] A i+1 i 1 0L System.out.println(ans) System.out.println System.out System System.out ans 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[] A = new Long[N+1];
        Long[] B = new Long[N];
        for(int i=0; i<N+1; i++){
            A[i] = sc.nextLong();
        }
        for(int i=0;i<N;i++){
            B[i] = sc.nextLong();
        }
    //処理
    Long ans = 0L;
        for(int i=0;i<N;i++){
            if(A[i]-B[i]>=0){A[i] -= B[i];ans+=B[i];}
            else{
                ans += A[i];
                B[i] -= A[i];
                A[i] = 0L;
                
                
                if(A[i+1]-B[i]>=0L){
                    A[i+1]-=B[i];
                    ans += B[i];
                }
                else if(A[i+1]-B[i]<0L){
                    ans += A[i+1];
                    A[i+1]=0L;
                }
            }
        }
        System.out.println(ans);
        sc.close();

    }
} public class Main{
    public static void main(String[] args){
    //入力
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Long[] A = new Long[N+1];
        Long[] B = new Long[N];
        for(int i=0; i<N+1; i++){
            A[i] = sc.nextLong();
        }
        for(int i=0;i<N;i++){
            B[i] = sc.nextLong();
        }
    //処理
    Long ans = 0L;
        for(int i=0;i<N;i++){
            if(A[i]-B[i]>=0){A[i] -= B[i];ans+=B[i];}
            else{
                ans += A[i];
                B[i] -= A[i];
                A[i] = 0L;
                
                
                if(A[i+1]-B[i]>=0L){
                    A[i+1]-=B[i];
                    ans += B[i];
                }
                else if(A[i+1]-B[i]<0L){
                    ans += A[i+1];
                    A[i+1]=0L;
                }
            }
        }
        System.out.println(ans);
        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[] A = new Long[N+1];
        Long[] B = new Long[N];
        for(int i=0; i<N+1; i++){
            A[i] = sc.nextLong();
        }
        for(int i=0;i<N;i++){
            B[i] = sc.nextLong();
        }
    //処理
    Long ans = 0L;
        for(int i=0;i<N;i++){
            if(A[i]-B[i]>=0){A[i] -= B[i];ans+=B[i];}
            else{
                ans += A[i];
                B[i] -= A[i];
                A[i] = 0L;
                
                
                if(A[i+1]-B[i]>=0L){
                    A[i+1]-=B[i];
                    ans += B[i];
                }
                else if(A[i+1]-B[i]<0L){
                    ans += A[i+1];
                    A[i+1]=0L;
                }
            }
        }
        System.out.println(ans);
        sc.close();

    }
}
