import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        long[] townmonster = new long[n+1];
        for(int i=0;i<n+1;i++){
            townmonster[i] = sc.nextLong();
        }

        long[] yusha = new long[n+1];
        for(int i=0;i<n;i++){
            yusha[i] = sc.nextLong();
        }
        yusha[n] = 0;

        long count =0;
        long yojou = 0;
        for(int i=0;i<n+1;i++){
            long target = townmonster[i];
            long yusha_yoryoku = yusha[i];
            if(target >= yusha_yoryoku + yojou){
                //System.out.println("if target=" + target + " yusha_yoryoku=" + yusha_yoryoku + " yojou=" + yojou + " count=" + count);
                count += yusha_yoryoku+yojou;
                yojou = 0;
            }else{
                //System.out.println("else target=" + target + " yusha_yoryoku=" + yusha_yoryoku+ " yojou=" + yojou + " count=" + count);
                count +=target;
                long nokori = target - yojou;
                if(nokori >0){
                    yojou = yusha_yoryoku-nokori;
                }else{
                    yojou = yusha_yoryoku;
                }
            }
        }
        System.out.println(count);




    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        long[] townmonster = new long[n+1];
        for(int i=0;i<n+1;i++){
            townmonster[i] = sc.nextLong();
        }

        long[] yusha = new long[n+1];
        for(int i=0;i<n;i++){
            yusha[i] = sc.nextLong();
        }
        yusha[n] = 0;

        long count =0;
        long yojou = 0;
        for(int i=0;i<n+1;i++){
            long target = townmonster[i];
            long yusha_yoryoku = yusha[i];
            if(target >= yusha_yoryoku + yojou){
                //System.out.println("if target=" + target + " yusha_yoryoku=" + yusha_yoryoku + " yojou=" + yojou + " count=" + count);
                count += yusha_yoryoku+yojou;
                yojou = 0;
            }else{
                //System.out.println("else target=" + target + " yusha_yoryoku=" + yusha_yoryoku+ " yojou=" + yojou + " count=" + count);
                count +=target;
                long nokori = target - yojou;
                if(nokori >0){
                    yojou = yusha_yoryoku-nokori;
                }else{
                    yojou = yusha_yoryoku;
                }
            }
        }
        System.out.println(count);




    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        long[] townmonster = new long[n+1];
        for(int i=0;i<n+1;i++){
            townmonster[i] = sc.nextLong();
        }

        long[] yusha = new long[n+1];
        for(int i=0;i<n;i++){
            yusha[i] = sc.nextLong();
        }
        yusha[n] = 0;

        long count =0;
        long yojou = 0;
        for(int i=0;i<n+1;i++){
            long target = townmonster[i];
            long yusha_yoryoku = yusha[i];
            if(target >= yusha_yoryoku + yojou){
                //System.out.println("if target=" + target + " yusha_yoryoku=" + yusha_yoryoku + " yojou=" + yojou + " count=" + count);
                count += yusha_yoryoku+yojou;
                yojou = 0;
            }else{
                //System.out.println("else target=" + target + " yusha_yoryoku=" + yusha_yoryoku+ " yojou=" + yojou + " count=" + count);
                count +=target;
                long nokori = target - yojou;
                if(nokori >0){
                    yojou = yusha_yoryoku-nokori;
                }else{
                    yojou = yusha_yoryoku;
                }
            }
        }
        System.out.println(count);




    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        long[] townmonster = new long[n+1];
        for(int i=0;i<n+1;i++){
            townmonster[i] = sc.nextLong();
        }

        long[] yusha = new long[n+1];
        for(int i=0;i<n;i++){
            yusha[i] = sc.nextLong();
        }
        yusha[n] = 0;

        long count =0;
        long yojou = 0;
        for(int i=0;i<n+1;i++){
            long target = townmonster[i];
            long yusha_yoryoku = yusha[i];
            if(target >= yusha_yoryoku + yojou){
                //System.out.println("if target=" + target + " yusha_yoryoku=" + yusha_yoryoku + " yojou=" + yojou + " count=" + count);
                count += yusha_yoryoku+yojou;
                yojou = 0;
            }else{
                //System.out.println("else target=" + target + " yusha_yoryoku=" + yusha_yoryoku+ " yojou=" + yojou + " count=" + count);
                count +=target;
                long nokori = target - yojou;
                if(nokori >0){
                    yojou = yusha_yoryoku-nokori;
                }else{
                    yojou = yusha_yoryoku;
                }
            }
        }
        System.out.println(count);




    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc long[] townmonster = new long[n+1]; townmonster new long[n+1] n+1 n 1 for(int i=0;i<n+1;i++){
            townmonster[i] = sc.nextLong();
        } int i=0; int i=0; i 0 i<n+1 i n+1 n 1 i++ i++ i {
            townmonster[i] = sc.nextLong();
        } {
            townmonster[i] = sc.nextLong();
        } townmonster[i] = sc.nextLong() townmonster[i] townmonster i sc.nextLong() sc.nextLong sc long[] yusha = new long[n+1]; yusha new long[n+1] n+1 n 1 for(int i=0;i<n;i++){
            yusha[i] = sc.nextLong();
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            yusha[i] = sc.nextLong();
        } {
            yusha[i] = sc.nextLong();
        } yusha[i] = sc.nextLong() yusha[i] yusha i sc.nextLong() sc.nextLong sc yusha[n] = 0 yusha[n] yusha n 0 long count =0; count 0 long yojou = 0; yojou 0 for(int i=0;i<n+1;i++){
            long target = townmonster[i];
            long yusha_yoryoku = yusha[i];
            if(target >= yusha_yoryoku + yojou){
                //System.out.println("if target=" + target + " yusha_yoryoku=" + yusha_yoryoku + " yojou=" + yojou + " count=" + count);
                count += yusha_yoryoku+yojou;
                yojou = 0;
            }else{
                //System.out.println("else target=" + target + " yusha_yoryoku=" + yusha_yoryoku+ " yojou=" + yojou + " count=" + count);
                count +=target;
                long nokori = target - yojou;
                if(nokori >0){
                    yojou = yusha_yoryoku-nokori;
                }else{
                    yojou = yusha_yoryoku;
                }
            }
        } int i=0; int i=0; i 0 i<n+1 i n+1 n 1 i++ i++ i {
            long target = townmonster[i];
            long yusha_yoryoku = yusha[i];
            if(target >= yusha_yoryoku + yojou){
                //System.out.println("if target=" + target + " yusha_yoryoku=" + yusha_yoryoku + " yojou=" + yojou + " count=" + count);
                count += yusha_yoryoku+yojou;
                yojou = 0;
            }else{
                //System.out.println("else target=" + target + " yusha_yoryoku=" + yusha_yoryoku+ " yojou=" + yojou + " count=" + count);
                count +=target;
                long nokori = target - yojou;
                if(nokori >0){
                    yojou = yusha_yoryoku-nokori;
                }else{
                    yojou = yusha_yoryoku;
                }
            }
        } {
            long target = townmonster[i];
            long yusha_yoryoku = yusha[i];
            if(target >= yusha_yoryoku + yojou){
                //System.out.println("if target=" + target + " yusha_yoryoku=" + yusha_yoryoku + " yojou=" + yojou + " count=" + count);
                count += yusha_yoryoku+yojou;
                yojou = 0;
            }else{
                //System.out.println("else target=" + target + " yusha_yoryoku=" + yusha_yoryoku+ " yojou=" + yojou + " count=" + count);
                count +=target;
                long nokori = target - yojou;
                if(nokori >0){
                    yojou = yusha_yoryoku-nokori;
                }else{
                    yojou = yusha_yoryoku;
                }
            }
        } long target = townmonster[i]; target townmonster[i] townmonster i long yusha_yoryoku = yusha[i]; yusha_yoryoku yusha[i] yusha i if(target >= yusha_yoryoku + yojou){
                //System.out.println("if target=" + target + " yusha_yoryoku=" + yusha_yoryoku + " yojou=" + yojou + " count=" + count);
                count += yusha_yoryoku+yojou;
                yojou = 0;
            }else{
                //System.out.println("else target=" + target + " yusha_yoryoku=" + yusha_yoryoku+ " yojou=" + yojou + " count=" + count);
                count +=target;
                long nokori = target - yojou;
                if(nokori >0){
                    yojou = yusha_yoryoku-nokori;
                }else{
                    yojou = yusha_yoryoku;
                }
            } target >= yusha_yoryoku + yojou target yusha_yoryoku + yojou yusha_yoryoku yojou {
                //System.out.println("if target=" + target + " yusha_yoryoku=" + yusha_yoryoku + " yojou=" + yojou + " count=" + count);
                count += yusha_yoryoku+yojou;
                yojou = 0;
            } count += yusha_yoryoku+yojou count yusha_yoryoku+yojou yusha_yoryoku yojou yojou = 0 yojou 0 {
                //System.out.println("else target=" + target + " yusha_yoryoku=" + yusha_yoryoku+ " yojou=" + yojou + " count=" + count);
                count +=target;
                long nokori = target - yojou;
                if(nokori >0){
                    yojou = yusha_yoryoku-nokori;
                }else{
                    yojou = yusha_yoryoku;
                }
            } count +=target count target long nokori = target - yojou; nokori target - yojou target yojou if(nokori >0){
                    yojou = yusha_yoryoku-nokori;
                }else{
                    yojou = yusha_yoryoku;
                } nokori >0 nokori 0 {
                    yojou = yusha_yoryoku-nokori;
                } yojou = yusha_yoryoku-nokori yojou yusha_yoryoku-nokori yusha_yoryoku nokori {
                    yojou = yusha_yoryoku;
                } yojou = yusha_yoryoku yojou yusha_yoryoku System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        long[] townmonster = new long[n+1];
        for(int i=0;i<n+1;i++){
            townmonster[i] = sc.nextLong();
        }

        long[] yusha = new long[n+1];
        for(int i=0;i<n;i++){
            yusha[i] = sc.nextLong();
        }
        yusha[n] = 0;

        long count =0;
        long yojou = 0;
        for(int i=0;i<n+1;i++){
            long target = townmonster[i];
            long yusha_yoryoku = yusha[i];
            if(target >= yusha_yoryoku + yojou){
                //System.out.println("if target=" + target + " yusha_yoryoku=" + yusha_yoryoku + " yojou=" + yojou + " count=" + count);
                count += yusha_yoryoku+yojou;
                yojou = 0;
            }else{
                //System.out.println("else target=" + target + " yusha_yoryoku=" + yusha_yoryoku+ " yojou=" + yojou + " count=" + count);
                count +=target;
                long nokori = target - yojou;
                if(nokori >0){
                    yojou = yusha_yoryoku-nokori;
                }else{
                    yojou = yusha_yoryoku;
                }
            }
        }
        System.out.println(count);




    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        long[] townmonster = new long[n+1];
        for(int i=0;i<n+1;i++){
            townmonster[i] = sc.nextLong();
        }

        long[] yusha = new long[n+1];
        for(int i=0;i<n;i++){
            yusha[i] = sc.nextLong();
        }
        yusha[n] = 0;

        long count =0;
        long yojou = 0;
        for(int i=0;i<n+1;i++){
            long target = townmonster[i];
            long yusha_yoryoku = yusha[i];
            if(target >= yusha_yoryoku + yojou){
                //System.out.println("if target=" + target + " yusha_yoryoku=" + yusha_yoryoku + " yojou=" + yojou + " count=" + count);
                count += yusha_yoryoku+yojou;
                yojou = 0;
            }else{
                //System.out.println("else target=" + target + " yusha_yoryoku=" + yusha_yoryoku+ " yojou=" + yojou + " count=" + count);
                count +=target;
                long nokori = target - yojou;
                if(nokori >0){
                    yojou = yusha_yoryoku-nokori;
                }else{
                    yojou = yusha_yoryoku;
                }
            }
        }
        System.out.println(count);




    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        long[] townmonster = new long[n+1];
        for(int i=0;i<n+1;i++){
            townmonster[i] = sc.nextLong();
        }

        long[] yusha = new long[n+1];
        for(int i=0;i<n;i++){
            yusha[i] = sc.nextLong();
        }
        yusha[n] = 0;

        long count =0;
        long yojou = 0;
        for(int i=0;i<n+1;i++){
            long target = townmonster[i];
            long yusha_yoryoku = yusha[i];
            if(target >= yusha_yoryoku + yojou){
                //System.out.println("if target=" + target + " yusha_yoryoku=" + yusha_yoryoku + " yojou=" + yojou + " count=" + count);
                count += yusha_yoryoku+yojou;
                yojou = 0;
            }else{
                //System.out.println("else target=" + target + " yusha_yoryoku=" + yusha_yoryoku+ " yojou=" + yojou + " count=" + count);
                count +=target;
                long nokori = target - yojou;
                if(nokori >0){
                    yojou = yusha_yoryoku-nokori;
                }else{
                    yojou = yusha_yoryoku;
                }
            }
        }
        System.out.println(count);




    }
}