import java.util.Scanner;

public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        final int NUM = scan.nextInt();
        int[] town = new int[NUM+1];
        int[] hero = new int[NUM];
        for(int i = 0; i < NUM + 1; i++){
            town[i] = scan.nextInt();
        }
        for(int i = 0; i < NUM; i++){
            hero[i] = scan.nextInt();
        }

        // search
        long sum = 0;
        int temp = Math.min(town[0], hero[0]);
        town[0] -= temp;
        hero[0] -= temp;
        sum += temp;
        for(int i = 1; i < NUM; i++){
            temp = Math.min(town[i], hero[i - 1]);
            town[i] -= temp;
            hero[i - 1] -= temp;
            sum += temp;
            temp = Math.min(town[i], hero[i]);
            town[i] -= temp;
            hero[i] -= temp;
            sum += temp;
        }
        temp = Math.min(town[NUM], hero[NUM - 1]);
        town[NUM] -= temp;
        hero[NUM - 1] -= temp;
        sum += temp;

        // answer
        System.out.println(sum);


        
    }
} import java.util.Scanner; Scanner java.util public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        final int NUM = scan.nextInt();
        int[] town = new int[NUM+1];
        int[] hero = new int[NUM];
        for(int i = 0; i < NUM + 1; i++){
            town[i] = scan.nextInt();
        }
        for(int i = 0; i < NUM; i++){
            hero[i] = scan.nextInt();
        }

        // search
        long sum = 0;
        int temp = Math.min(town[0], hero[0]);
        town[0] -= temp;
        hero[0] -= temp;
        sum += temp;
        for(int i = 1; i < NUM; i++){
            temp = Math.min(town[i], hero[i - 1]);
            town[i] -= temp;
            hero[i - 1] -= temp;
            sum += temp;
            temp = Math.min(town[i], hero[i]);
            town[i] -= temp;
            hero[i] -= temp;
            sum += temp;
        }
        temp = Math.min(town[NUM], hero[NUM - 1]);
        town[NUM] -= temp;
        hero[NUM - 1] -= temp;
        sum += temp;

        // answer
        System.out.println(sum);


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

        // input
        final int NUM = scan.nextInt();
        int[] town = new int[NUM+1];
        int[] hero = new int[NUM];
        for(int i = 0; i < NUM + 1; i++){
            town[i] = scan.nextInt();
        }
        for(int i = 0; i < NUM; i++){
            hero[i] = scan.nextInt();
        }

        // search
        long sum = 0;
        int temp = Math.min(town[0], hero[0]);
        town[0] -= temp;
        hero[0] -= temp;
        sum += temp;
        for(int i = 1; i < NUM; i++){
            temp = Math.min(town[i], hero[i - 1]);
            town[i] -= temp;
            hero[i - 1] -= temp;
            sum += temp;
            temp = Math.min(town[i], hero[i]);
            town[i] -= temp;
            hero[i] -= temp;
            sum += temp;
        }
        temp = Math.min(town[NUM], hero[NUM - 1]);
        town[NUM] -= temp;
        hero[NUM - 1] -= temp;
        sum += temp;

        // answer
        System.out.println(sum);


        
    } main {
        Scanner scan = new Scanner(System.in);

        // input
        final int NUM = scan.nextInt();
        int[] town = new int[NUM+1];
        int[] hero = new int[NUM];
        for(int i = 0; i < NUM + 1; i++){
            town[i] = scan.nextInt();
        }
        for(int i = 0; i < NUM; i++){
            hero[i] = scan.nextInt();
        }

        // search
        long sum = 0;
        int temp = Math.min(town[0], hero[0]);
        town[0] -= temp;
        hero[0] -= temp;
        sum += temp;
        for(int i = 1; i < NUM; i++){
            temp = Math.min(town[i], hero[i - 1]);
            town[i] -= temp;
            hero[i - 1] -= temp;
            sum += temp;
            temp = Math.min(town[i], hero[i]);
            town[i] -= temp;
            hero[i] -= temp;
            sum += temp;
        }
        temp = Math.min(town[NUM], hero[NUM - 1]);
        town[NUM] -= temp;
        hero[NUM - 1] -= temp;
        sum += temp;

        // answer
        System.out.println(sum);


        
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) final int NUM = scan.nextInt(); NUM scan.nextInt() scan.nextInt scan int[] town = new int[NUM+1]; town new int[NUM+1] NUM+1 NUM 1 int[] hero = new int[NUM]; hero new int[NUM] NUM for(int i = 0; i < NUM + 1; i++){
            town[i] = scan.nextInt();
        } int i = 0; int i = 0; i 0 i < NUM + 1 i NUM + 1 NUM 1 i++ i++ i {
            town[i] = scan.nextInt();
        } {
            town[i] = scan.nextInt();
        } town[i] = scan.nextInt() town[i] town i scan.nextInt() scan.nextInt scan for(int i = 0; i < NUM; i++){
            hero[i] = scan.nextInt();
        } int i = 0; int i = 0; i 0 i < NUM i NUM i++ i++ i {
            hero[i] = scan.nextInt();
        } {
            hero[i] = scan.nextInt();
        } hero[i] = scan.nextInt() hero[i] hero i scan.nextInt() scan.nextInt scan long sum = 0; sum 0 int temp = Math.min(town[0], hero[0]); temp Math.min(town[0], hero[0]) Math.min Math town[0] town 0 hero[0] hero 0 town[0] -= temp town[0] town 0 temp hero[0] -= temp hero[0] hero 0 temp sum += temp sum temp for(int i = 1; i < NUM; i++){
            temp = Math.min(town[i], hero[i - 1]);
            town[i] -= temp;
            hero[i - 1] -= temp;
            sum += temp;
            temp = Math.min(town[i], hero[i]);
            town[i] -= temp;
            hero[i] -= temp;
            sum += temp;
        } int i = 1; int i = 1; i 1 i < NUM i NUM i++ i++ i {
            temp = Math.min(town[i], hero[i - 1]);
            town[i] -= temp;
            hero[i - 1] -= temp;
            sum += temp;
            temp = Math.min(town[i], hero[i]);
            town[i] -= temp;
            hero[i] -= temp;
            sum += temp;
        } {
            temp = Math.min(town[i], hero[i - 1]);
            town[i] -= temp;
            hero[i - 1] -= temp;
            sum += temp;
            temp = Math.min(town[i], hero[i]);
            town[i] -= temp;
            hero[i] -= temp;
            sum += temp;
        } temp = Math.min(town[i], hero[i - 1]) temp Math.min(town[i], hero[i - 1]) Math.min Math town[i] town i hero[i - 1] hero i - 1 i 1 town[i] -= temp town[i] town i temp hero[i - 1] -= temp hero[i - 1] hero i - 1 i 1 temp sum += temp sum temp temp = Math.min(town[i], hero[i]) temp Math.min(town[i], hero[i]) Math.min Math town[i] town i hero[i] hero i town[i] -= temp town[i] town i temp hero[i] -= temp hero[i] hero i temp sum += temp sum temp temp = Math.min(town[NUM], hero[NUM - 1]) temp Math.min(town[NUM], hero[NUM - 1]) Math.min Math town[NUM] town NUM hero[NUM - 1] hero NUM - 1 NUM 1 town[NUM] -= temp town[NUM] town NUM temp hero[NUM - 1] -= temp hero[NUM - 1] hero NUM - 1 NUM 1 temp sum += temp sum temp System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        final int NUM = scan.nextInt();
        int[] town = new int[NUM+1];
        int[] hero = new int[NUM];
        for(int i = 0; i < NUM + 1; i++){
            town[i] = scan.nextInt();
        }
        for(int i = 0; i < NUM; i++){
            hero[i] = scan.nextInt();
        }

        // search
        long sum = 0;
        int temp = Math.min(town[0], hero[0]);
        town[0] -= temp;
        hero[0] -= temp;
        sum += temp;
        for(int i = 1; i < NUM; i++){
            temp = Math.min(town[i], hero[i - 1]);
            town[i] -= temp;
            hero[i - 1] -= temp;
            sum += temp;
            temp = Math.min(town[i], hero[i]);
            town[i] -= temp;
            hero[i] -= temp;
            sum += temp;
        }
        temp = Math.min(town[NUM], hero[NUM - 1]);
        town[NUM] -= temp;
        hero[NUM - 1] -= temp;
        sum += temp;

        // answer
        System.out.println(sum);


        
    }
} public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        final int NUM = scan.nextInt();
        int[] town = new int[NUM+1];
        int[] hero = new int[NUM];
        for(int i = 0; i < NUM + 1; i++){
            town[i] = scan.nextInt();
        }
        for(int i = 0; i < NUM; i++){
            hero[i] = scan.nextInt();
        }

        // search
        long sum = 0;
        int temp = Math.min(town[0], hero[0]);
        town[0] -= temp;
        hero[0] -= temp;
        sum += temp;
        for(int i = 1; i < NUM; i++){
            temp = Math.min(town[i], hero[i - 1]);
            town[i] -= temp;
            hero[i - 1] -= temp;
            sum += temp;
            temp = Math.min(town[i], hero[i]);
            town[i] -= temp;
            hero[i] -= temp;
            sum += temp;
        }
        temp = Math.min(town[NUM], hero[NUM - 1]);
        town[NUM] -= temp;
        hero[NUM - 1] -= temp;
        sum += temp;

        // answer
        System.out.println(sum);


        
    }
} Main
import java.util.Scanner;

public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        final int NUM = scan.nextInt();
        int[] town = new int[NUM+1];
        int[] hero = new int[NUM];
        for(int i = 0; i < NUM + 1; i++){
            town[i] = scan.nextInt();
        }
        for(int i = 0; i < NUM; i++){
            hero[i] = scan.nextInt();
        }

        // search
        long sum = 0;
        int temp = Math.min(town[0], hero[0]);
        town[0] -= temp;
        hero[0] -= temp;
        sum += temp;
        for(int i = 1; i < NUM; i++){
            temp = Math.min(town[i], hero[i - 1]);
            town[i] -= temp;
            hero[i - 1] -= temp;
            sum += temp;
            temp = Math.min(town[i], hero[i]);
            town[i] -= temp;
            hero[i] -= temp;
            sum += temp;
        }
        temp = Math.min(town[NUM], hero[NUM - 1]);
        town[NUM] -= temp;
        hero[NUM - 1] -= temp;
        sum += temp;

        // answer
        System.out.println(sum);


        
    }
}