import java.util.*;

import javax.swing.plaf.synth.SynthSplitPaneUI;

public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        List<Integer> A = new ArrayList<>();
        for(int i= 0;i<N+1;i++){
            int a = scanner.nextInt();
            A.add(a);
        }
        List<Integer> B = new ArrayList<>();
        for(int i= 0;i<N;i++){
            int b = scanner.nextInt();
            B.add(b);
        }

        Map<List<Integer>, Integer> x = new HashMap<>();
        for(int i=0; i<N; i++){
            List<Integer> ii = new ArrayList<>(Arrays.asList(i, i));
            List<Integer> iminus1i = new ArrayList<>(Arrays.asList(i-1,i));
            List<Integer> iiplus1 = new ArrayList<>(Arrays.asList(i, i+1));
            if(i==0){
                x.put(ii, Math.min(A.get(i), B.get(i)));
            }else{
                x.put(ii, Math.min(A.get(i) - x.get(iminus1i), B.get(i)));
            }
            x.put(iiplus1, Math.min(B.get(i) - x.get(ii), A.get(i+1)));
        }
        long result = 0;
        for(Integer val: x.values()){
            result += val;
        }
        System.out.println(result);
    }
} import java.util.*; util.* java import javax.swing.plaf.synth.SynthSplitPaneUI; SynthSplitPaneUI javax.swing.plaf.synth public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        List<Integer> A = new ArrayList<>();
        for(int i= 0;i<N+1;i++){
            int a = scanner.nextInt();
            A.add(a);
        }
        List<Integer> B = new ArrayList<>();
        for(int i= 0;i<N;i++){
            int b = scanner.nextInt();
            B.add(b);
        }

        Map<List<Integer>, Integer> x = new HashMap<>();
        for(int i=0; i<N; i++){
            List<Integer> ii = new ArrayList<>(Arrays.asList(i, i));
            List<Integer> iminus1i = new ArrayList<>(Arrays.asList(i-1,i));
            List<Integer> iiplus1 = new ArrayList<>(Arrays.asList(i, i+1));
            if(i==0){
                x.put(ii, Math.min(A.get(i), B.get(i)));
            }else{
                x.put(ii, Math.min(A.get(i) - x.get(iminus1i), B.get(i)));
            }
            x.put(iiplus1, Math.min(B.get(i) - x.get(ii), A.get(i+1)));
        }
        long result = 0;
        for(Integer val: x.values()){
            result += val;
        }
        System.out.println(result);
    }
} Main public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        List<Integer> A = new ArrayList<>();
        for(int i= 0;i<N+1;i++){
            int a = scanner.nextInt();
            A.add(a);
        }
        List<Integer> B = new ArrayList<>();
        for(int i= 0;i<N;i++){
            int b = scanner.nextInt();
            B.add(b);
        }

        Map<List<Integer>, Integer> x = new HashMap<>();
        for(int i=0; i<N; i++){
            List<Integer> ii = new ArrayList<>(Arrays.asList(i, i));
            List<Integer> iminus1i = new ArrayList<>(Arrays.asList(i-1,i));
            List<Integer> iiplus1 = new ArrayList<>(Arrays.asList(i, i+1));
            if(i==0){
                x.put(ii, Math.min(A.get(i), B.get(i)));
            }else{
                x.put(ii, Math.min(A.get(i) - x.get(iminus1i), B.get(i)));
            }
            x.put(iiplus1, Math.min(B.get(i) - x.get(ii), A.get(i+1)));
        }
        long result = 0;
        for(Integer val: x.values()){
            result += val;
        }
        System.out.println(result);
    } main {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        List<Integer> A = new ArrayList<>();
        for(int i= 0;i<N+1;i++){
            int a = scanner.nextInt();
            A.add(a);
        }
        List<Integer> B = new ArrayList<>();
        for(int i= 0;i<N;i++){
            int b = scanner.nextInt();
            B.add(b);
        }

        Map<List<Integer>, Integer> x = new HashMap<>();
        for(int i=0; i<N; i++){
            List<Integer> ii = new ArrayList<>(Arrays.asList(i, i));
            List<Integer> iminus1i = new ArrayList<>(Arrays.asList(i-1,i));
            List<Integer> iiplus1 = new ArrayList<>(Arrays.asList(i, i+1));
            if(i==0){
                x.put(ii, Math.min(A.get(i), B.get(i)));
            }else{
                x.put(ii, Math.min(A.get(i) - x.get(iminus1i), B.get(i)));
            }
            x.put(iiplus1, Math.min(B.get(i) - x.get(ii), A.get(i+1)));
        }
        long result = 0;
        for(Integer val: x.values()){
            result += val;
        }
        System.out.println(result);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner List<Integer> A = new ArrayList<>(); A new ArrayList<>() for(int i= 0;i<N+1;i++){
            int a = scanner.nextInt();
            A.add(a);
        } int i= 0; int i= 0; i 0 i<N+1 i N+1 N 1 i++ i++ i {
            int a = scanner.nextInt();
            A.add(a);
        } {
            int a = scanner.nextInt();
            A.add(a);
        } int a = scanner.nextInt(); a scanner.nextInt() scanner.nextInt scanner A.add(a) A.add A a List<Integer> B = new ArrayList<>(); B new ArrayList<>() for(int i= 0;i<N;i++){
            int b = scanner.nextInt();
            B.add(b);
        } int i= 0; int i= 0; i 0 i<N i N i++ i++ i {
            int b = scanner.nextInt();
            B.add(b);
        } {
            int b = scanner.nextInt();
            B.add(b);
        } int b = scanner.nextInt(); b scanner.nextInt() scanner.nextInt scanner B.add(b) B.add B b Map<List<Integer>, Integer> x = new HashMap<>(); x new HashMap<>() for(int i=0; i<N; i++){
            List<Integer> ii = new ArrayList<>(Arrays.asList(i, i));
            List<Integer> iminus1i = new ArrayList<>(Arrays.asList(i-1,i));
            List<Integer> iiplus1 = new ArrayList<>(Arrays.asList(i, i+1));
            if(i==0){
                x.put(ii, Math.min(A.get(i), B.get(i)));
            }else{
                x.put(ii, Math.min(A.get(i) - x.get(iminus1i), B.get(i)));
            }
            x.put(iiplus1, Math.min(B.get(i) - x.get(ii), A.get(i+1)));
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            List<Integer> ii = new ArrayList<>(Arrays.asList(i, i));
            List<Integer> iminus1i = new ArrayList<>(Arrays.asList(i-1,i));
            List<Integer> iiplus1 = new ArrayList<>(Arrays.asList(i, i+1));
            if(i==0){
                x.put(ii, Math.min(A.get(i), B.get(i)));
            }else{
                x.put(ii, Math.min(A.get(i) - x.get(iminus1i), B.get(i)));
            }
            x.put(iiplus1, Math.min(B.get(i) - x.get(ii), A.get(i+1)));
        } {
            List<Integer> ii = new ArrayList<>(Arrays.asList(i, i));
            List<Integer> iminus1i = new ArrayList<>(Arrays.asList(i-1,i));
            List<Integer> iiplus1 = new ArrayList<>(Arrays.asList(i, i+1));
            if(i==0){
                x.put(ii, Math.min(A.get(i), B.get(i)));
            }else{
                x.put(ii, Math.min(A.get(i) - x.get(iminus1i), B.get(i)));
            }
            x.put(iiplus1, Math.min(B.get(i) - x.get(ii), A.get(i+1)));
        } List<Integer> ii = new ArrayList<>(Arrays.asList(i, i)); ii new ArrayList<>(Arrays.asList(i, i)) List<Integer> iminus1i = new ArrayList<>(Arrays.asList(i-1,i)); iminus1i new ArrayList<>(Arrays.asList(i-1,i)) List<Integer> iiplus1 = new ArrayList<>(Arrays.asList(i, i+1)); iiplus1 new ArrayList<>(Arrays.asList(i, i+1)) if(i==0){
                x.put(ii, Math.min(A.get(i), B.get(i)));
            }else{
                x.put(ii, Math.min(A.get(i) - x.get(iminus1i), B.get(i)));
            } i==0 i 0 {
                x.put(ii, Math.min(A.get(i), B.get(i)));
            } x.put(ii, Math.min(A.get(i), B.get(i))) x.put x ii Math.min(A.get(i), B.get(i)) Math.min Math A.get(i) A.get A i B.get(i) B.get B i {
                x.put(ii, Math.min(A.get(i) - x.get(iminus1i), B.get(i)));
            } x.put(ii, Math.min(A.get(i) - x.get(iminus1i), B.get(i))) x.put x ii Math.min(A.get(i) - x.get(iminus1i), B.get(i)) Math.min Math A.get(i) - x.get(iminus1i) A.get(i) A.get A i x.get(iminus1i) x.get x iminus1i B.get(i) B.get B i x.put(iiplus1, Math.min(B.get(i) - x.get(ii), A.get(i+1))) x.put x iiplus1 Math.min(B.get(i) - x.get(ii), A.get(i+1)) Math.min Math B.get(i) - x.get(ii) B.get(i) B.get B i x.get(ii) x.get x ii A.get(i+1) A.get A i+1 i 1 long result = 0; result 0 for(Integer val: x.values()){
            result += val;
        } Integer val x.values() x.values x {
            result += val;
        } {
            result += val;
        } result += val result val System.out.println(result) System.out.println System.out System System.out result String args[] args public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        List<Integer> A = new ArrayList<>();
        for(int i= 0;i<N+1;i++){
            int a = scanner.nextInt();
            A.add(a);
        }
        List<Integer> B = new ArrayList<>();
        for(int i= 0;i<N;i++){
            int b = scanner.nextInt();
            B.add(b);
        }

        Map<List<Integer>, Integer> x = new HashMap<>();
        for(int i=0; i<N; i++){
            List<Integer> ii = new ArrayList<>(Arrays.asList(i, i));
            List<Integer> iminus1i = new ArrayList<>(Arrays.asList(i-1,i));
            List<Integer> iiplus1 = new ArrayList<>(Arrays.asList(i, i+1));
            if(i==0){
                x.put(ii, Math.min(A.get(i), B.get(i)));
            }else{
                x.put(ii, Math.min(A.get(i) - x.get(iminus1i), B.get(i)));
            }
            x.put(iiplus1, Math.min(B.get(i) - x.get(ii), A.get(i+1)));
        }
        long result = 0;
        for(Integer val: x.values()){
            result += val;
        }
        System.out.println(result);
    }
} public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        List<Integer> A = new ArrayList<>();
        for(int i= 0;i<N+1;i++){
            int a = scanner.nextInt();
            A.add(a);
        }
        List<Integer> B = new ArrayList<>();
        for(int i= 0;i<N;i++){
            int b = scanner.nextInt();
            B.add(b);
        }

        Map<List<Integer>, Integer> x = new HashMap<>();
        for(int i=0; i<N; i++){
            List<Integer> ii = new ArrayList<>(Arrays.asList(i, i));
            List<Integer> iminus1i = new ArrayList<>(Arrays.asList(i-1,i));
            List<Integer> iiplus1 = new ArrayList<>(Arrays.asList(i, i+1));
            if(i==0){
                x.put(ii, Math.min(A.get(i), B.get(i)));
            }else{
                x.put(ii, Math.min(A.get(i) - x.get(iminus1i), B.get(i)));
            }
            x.put(iiplus1, Math.min(B.get(i) - x.get(ii), A.get(i+1)));
        }
        long result = 0;
        for(Integer val: x.values()){
            result += val;
        }
        System.out.println(result);
    }
} Main
import java.util.*;

import javax.swing.plaf.synth.SynthSplitPaneUI;

public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        List<Integer> A = new ArrayList<>();
        for(int i= 0;i<N+1;i++){
            int a = scanner.nextInt();
            A.add(a);
        }
        List<Integer> B = new ArrayList<>();
        for(int i= 0;i<N;i++){
            int b = scanner.nextInt();
            B.add(b);
        }

        Map<List<Integer>, Integer> x = new HashMap<>();
        for(int i=0; i<N; i++){
            List<Integer> ii = new ArrayList<>(Arrays.asList(i, i));
            List<Integer> iminus1i = new ArrayList<>(Arrays.asList(i-1,i));
            List<Integer> iiplus1 = new ArrayList<>(Arrays.asList(i, i+1));
            if(i==0){
                x.put(ii, Math.min(A.get(i), B.get(i)));
            }else{
                x.put(ii, Math.min(A.get(i) - x.get(iminus1i), B.get(i)));
            }
            x.put(iiplus1, Math.min(B.get(i) - x.get(ii), A.get(i+1)));
        }
        long result = 0;
        for(Integer val: x.values()){
            result += val;
        }
        System.out.println(result);
    }
}