import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.List;

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


    }

}
 import java.awt.*; awt.* java import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.*; util.* java import java.util.List; List java.util public class Main {
    public static void main(String args[]) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int A[]=new int[n+1];
        int B[]=new int[n];
        for (int i=0;i<n+1;i++){
            A[i]=sc.nextInt();
        }
        for (int i=0;i<n;i++){
            B[i]=sc.nextInt();
        }
        long tot=0;
        for (int i=0;i<n;i++){
            if (B[i]>A[i]){
                B[i]-=A[i];
                tot+=A[i];
                if (B[i]>A[i+1]){
                    tot+=A[i+1];
                    A[i+1]=0;
                }else {
                    tot+=B[i];
                    A[i+1]-=B[i];
                }
            }else {
                tot+=B[i];
            }
        }
        System.out.println(tot);


    }

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


    } main {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int A[]=new int[n+1];
        int B[]=new int[n];
        for (int i=0;i<n+1;i++){
            A[i]=sc.nextInt();
        }
        for (int i=0;i<n;i++){
            B[i]=sc.nextInt();
        }
        long tot=0;
        for (int i=0;i<n;i++){
            if (B[i]>A[i]){
                B[i]-=A[i];
                tot+=A[i];
                if (B[i]>A[i+1]){
                    tot+=A[i+1];
                    A[i+1]=0;
                }else {
                    tot+=B[i];
                    A[i+1]-=B[i];
                }
            }else {
                tot+=B[i];
            }
        }
        System.out.println(tot);


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


    }

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


    }

} Main
import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.List;

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


    }

}

