import java.util.Scanner;
 
public class Main {
    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args){
        int n = stdIn.nextInt();
        int[] a = new int[n+1];
        for(int i=0; i<n+1; i++){
            a[i] = stdIn.nextInt();
        }
        int[] b = new int[n];
        for(int i=0; i<n; i++){
            b[i] = stdIn.nextInt();
        }

        long cnt = 0;
        for(int i=0; i<n; i++){
            if(a[i] >= b[i]){
                cnt += b[i];
                b[i] = 0;
            }else{
                cnt += a[i];
                b[i] -= a[i];

                if(a[i+1] >= b[i]){
                    cnt += b[i];
                    a[i+1] -= b[i];
                }else{
                    cnt += a[i+1];
                    a[i+1] = 0;
                }
            }
        }

        System.out.println(cnt);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args){
        int n = stdIn.nextInt();
        int[] a = new int[n+1];
        for(int i=0; i<n+1; i++){
            a[i] = stdIn.nextInt();
        }
        int[] b = new int[n];
        for(int i=0; i<n; i++){
            b[i] = stdIn.nextInt();
        }

        long cnt = 0;
        for(int i=0; i<n; i++){
            if(a[i] >= b[i]){
                cnt += b[i];
                b[i] = 0;
            }else{
                cnt += a[i];
                b[i] -= a[i];

                if(a[i+1] >= b[i]){
                    cnt += b[i];
                    a[i+1] -= b[i];
                }else{
                    cnt += a[i+1];
                    a[i+1] = 0;
                }
            }
        }

        System.out.println(cnt);
    }
} Main static Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) public static void main(String[] args){
        int n = stdIn.nextInt();
        int[] a = new int[n+1];
        for(int i=0; i<n+1; i++){
            a[i] = stdIn.nextInt();
        }
        int[] b = new int[n];
        for(int i=0; i<n; i++){
            b[i] = stdIn.nextInt();
        }

        long cnt = 0;
        for(int i=0; i<n; i++){
            if(a[i] >= b[i]){
                cnt += b[i];
                b[i] = 0;
            }else{
                cnt += a[i];
                b[i] -= a[i];

                if(a[i+1] >= b[i]){
                    cnt += b[i];
                    a[i+1] -= b[i];
                }else{
                    cnt += a[i+1];
                    a[i+1] = 0;
                }
            }
        }

        System.out.println(cnt);
    } main {
        int n = stdIn.nextInt();
        int[] a = new int[n+1];
        for(int i=0; i<n+1; i++){
            a[i] = stdIn.nextInt();
        }
        int[] b = new int[n];
        for(int i=0; i<n; i++){
            b[i] = stdIn.nextInt();
        }

        long cnt = 0;
        for(int i=0; i<n; i++){
            if(a[i] >= b[i]){
                cnt += b[i];
                b[i] = 0;
            }else{
                cnt += a[i];
                b[i] -= a[i];

                if(a[i+1] >= b[i]){
                    cnt += b[i];
                    a[i+1] -= b[i];
                }else{
                    cnt += a[i+1];
                    a[i+1] = 0;
                }
            }
        }

        System.out.println(cnt);
    } int n = stdIn.nextInt(); n stdIn.nextInt() stdIn.nextInt stdIn int[] a = new int[n+1]; a new int[n+1] n+1 n 1 for(int i=0; i<n+1; i++){
            a[i] = stdIn.nextInt();
        } int i=0; int i=0; i 0 i<n+1 i n+1 n 1 i++ i++ i {
            a[i] = stdIn.nextInt();
        } {
            a[i] = stdIn.nextInt();
        } a[i] = stdIn.nextInt() a[i] a i stdIn.nextInt() stdIn.nextInt stdIn int[] b = new int[n]; b new int[n] n for(int i=0; i<n; i++){
            b[i] = stdIn.nextInt();
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            b[i] = stdIn.nextInt();
        } {
            b[i] = stdIn.nextInt();
        } b[i] = stdIn.nextInt() b[i] b i stdIn.nextInt() stdIn.nextInt stdIn long cnt = 0; cnt 0 for(int i=0; i<n; i++){
            if(a[i] >= b[i]){
                cnt += b[i];
                b[i] = 0;
            }else{
                cnt += a[i];
                b[i] -= a[i];

                if(a[i+1] >= b[i]){
                    cnt += b[i];
                    a[i+1] -= b[i];
                }else{
                    cnt += 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]){
                cnt += b[i];
                b[i] = 0;
            }else{
                cnt += a[i];
                b[i] -= a[i];

                if(a[i+1] >= b[i]){
                    cnt += b[i];
                    a[i+1] -= b[i];
                }else{
                    cnt += a[i+1];
                    a[i+1] = 0;
                }
            }
        } {
            if(a[i] >= b[i]){
                cnt += b[i];
                b[i] = 0;
            }else{
                cnt += a[i];
                b[i] -= a[i];

                if(a[i+1] >= b[i]){
                    cnt += b[i];
                    a[i+1] -= b[i];
                }else{
                    cnt += a[i+1];
                    a[i+1] = 0;
                }
            }
        } if(a[i] >= b[i]){
                cnt += b[i];
                b[i] = 0;
            }else{
                cnt += a[i];
                b[i] -= a[i];

                if(a[i+1] >= b[i]){
                    cnt += b[i];
                    a[i+1] -= b[i];
                }else{
                    cnt += a[i+1];
                    a[i+1] = 0;
                }
            } a[i] >= b[i] a[i] a i b[i] b i {
                cnt += b[i];
                b[i] = 0;
            } cnt += b[i] cnt b[i] b i b[i] = 0 b[i] b i 0 {
                cnt += a[i];
                b[i] -= a[i];

                if(a[i+1] >= b[i]){
                    cnt += b[i];
                    a[i+1] -= b[i];
                }else{
                    cnt += a[i+1];
                    a[i+1] = 0;
                }
            } cnt += a[i] cnt a[i] a i b[i] -= a[i] b[i] b i a[i] a i if(a[i+1] >= b[i]){
                    cnt += b[i];
                    a[i+1] -= b[i];
                }else{
                    cnt += a[i+1];
                    a[i+1] = 0;
                } a[i+1] >= b[i] a[i+1] a i+1 i 1 b[i] b i {
                    cnt += b[i];
                    a[i+1] -= b[i];
                } cnt += b[i] cnt b[i] b i a[i+1] -= b[i] a[i+1] a i+1 i 1 b[i] b i {
                    cnt += a[i+1];
                    a[i+1] = 0;
                } cnt += a[i+1] cnt a[i+1] a i+1 i 1 a[i+1] = 0 a[i+1] a i+1 i 1 0 System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {
    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args){
        int n = stdIn.nextInt();
        int[] a = new int[n+1];
        for(int i=0; i<n+1; i++){
            a[i] = stdIn.nextInt();
        }
        int[] b = new int[n];
        for(int i=0; i<n; i++){
            b[i] = stdIn.nextInt();
        }

        long cnt = 0;
        for(int i=0; i<n; i++){
            if(a[i] >= b[i]){
                cnt += b[i];
                b[i] = 0;
            }else{
                cnt += a[i];
                b[i] -= a[i];

                if(a[i+1] >= b[i]){
                    cnt += b[i];
                    a[i+1] -= b[i];
                }else{
                    cnt += a[i+1];
                    a[i+1] = 0;
                }
            }
        }

        System.out.println(cnt);
    }
} public class Main {
    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args){
        int n = stdIn.nextInt();
        int[] a = new int[n+1];
        for(int i=0; i<n+1; i++){
            a[i] = stdIn.nextInt();
        }
        int[] b = new int[n];
        for(int i=0; i<n; i++){
            b[i] = stdIn.nextInt();
        }

        long cnt = 0;
        for(int i=0; i<n; i++){
            if(a[i] >= b[i]){
                cnt += b[i];
                b[i] = 0;
            }else{
                cnt += a[i];
                b[i] -= a[i];

                if(a[i+1] >= b[i]){
                    cnt += b[i];
                    a[i+1] -= b[i];
                }else{
                    cnt += a[i+1];
                    a[i+1] = 0;
                }
            }
        }

        System.out.println(cnt);
    }
} Main
import java.util.Scanner;
 
public class Main {
    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args){
        int n = stdIn.nextInt();
        int[] a = new int[n+1];
        for(int i=0; i<n+1; i++){
            a[i] = stdIn.nextInt();
        }
        int[] b = new int[n];
        for(int i=0; i<n; i++){
            b[i] = stdIn.nextInt();
        }

        long cnt = 0;
        for(int i=0; i<n; i++){
            if(a[i] >= b[i]){
                cnt += b[i];
                b[i] = 0;
            }else{
                cnt += a[i];
                b[i] -= a[i];

                if(a[i+1] >= b[i]){
                    cnt += b[i];
                    a[i+1] -= b[i];
                }else{
                    cnt += a[i+1];
                    a[i+1] = 0;
                }
            }
        }

        System.out.println(cnt);
    }
}
