import java.util.Scanner;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] arrayA = new int[a + 1];
        int[] arrayB = new int[a];
        
        for(int i = 0; i < a + 1; i++){
            arrayA[i] = sc.nextInt();
        }
        for(int i = 0; i < a; i++){
            arrayB[i] = sc.nextInt();
        }
        long sum = 0;
        for(int i = 0; i < a; i++){
            long n = Math.min(arrayA[i], arrayB[i]);
            sum += n;
            arrayA[i] -= n;
            arrayB[i] -= n;
            n = Math.min(arrayA[i + 1], arrayB[i]);
            sum += n;
            arrayA[i + 1] -= n;
            arrayB[i] -= n;
        }
        System.out.println(sum);
    }
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util public class Main {

	public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] arrayA = new int[a + 1];
        int[] arrayB = new int[a];
        
        for(int i = 0; i < a + 1; i++){
            arrayA[i] = sc.nextInt();
        }
        for(int i = 0; i < a; i++){
            arrayB[i] = sc.nextInt();
        }
        long sum = 0;
        for(int i = 0; i < a; i++){
            long n = Math.min(arrayA[i], arrayB[i]);
            sum += n;
            arrayA[i] -= n;
            arrayB[i] -= n;
            n = Math.min(arrayA[i + 1], arrayB[i]);
            sum += n;
            arrayA[i + 1] -= n;
            arrayB[i] -= n;
        }
        System.out.println(sum);
    }
} Main public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] arrayA = new int[a + 1];
        int[] arrayB = new int[a];
        
        for(int i = 0; i < a + 1; i++){
            arrayA[i] = sc.nextInt();
        }
        for(int i = 0; i < a; i++){
            arrayB[i] = sc.nextInt();
        }
        long sum = 0;
        for(int i = 0; i < a; i++){
            long n = Math.min(arrayA[i], arrayB[i]);
            sum += n;
            arrayA[i] -= n;
            arrayB[i] -= n;
            n = Math.min(arrayA[i + 1], arrayB[i]);
            sum += n;
            arrayA[i + 1] -= n;
            arrayB[i] -= n;
        }
        System.out.println(sum);
    } main {
       
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] arrayA = new int[a + 1];
        int[] arrayB = new int[a];
        
        for(int i = 0; i < a + 1; i++){
            arrayA[i] = sc.nextInt();
        }
        for(int i = 0; i < a; i++){
            arrayB[i] = sc.nextInt();
        }
        long sum = 0;
        for(int i = 0; i < a; i++){
            long n = Math.min(arrayA[i], arrayB[i]);
            sum += n;
            arrayA[i] -= n;
            arrayB[i] -= n;
            n = Math.min(arrayA[i + 1], arrayB[i]);
            sum += n;
            arrayA[i + 1] -= n;
            arrayB[i] -= n;
        }
        System.out.println(sum);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int[] arrayA = new int[a + 1]; arrayA new int[a + 1] a + 1 a 1 int[] arrayB = new int[a]; arrayB new int[a] a for(int i = 0; i < a + 1; i++){
            arrayA[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < a + 1 i a + 1 a 1 i++ i++ i {
            arrayA[i] = sc.nextInt();
        } {
            arrayA[i] = sc.nextInt();
        } arrayA[i] = sc.nextInt() arrayA[i] arrayA i sc.nextInt() sc.nextInt sc for(int i = 0; i < a; i++){
            arrayB[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < a i a i++ i++ i {
            arrayB[i] = sc.nextInt();
        } {
            arrayB[i] = sc.nextInt();
        } arrayB[i] = sc.nextInt() arrayB[i] arrayB i sc.nextInt() sc.nextInt sc long sum = 0; sum 0 for(int i = 0; i < a; i++){
            long n = Math.min(arrayA[i], arrayB[i]);
            sum += n;
            arrayA[i] -= n;
            arrayB[i] -= n;
            n = Math.min(arrayA[i + 1], arrayB[i]);
            sum += n;
            arrayA[i + 1] -= n;
            arrayB[i] -= n;
        } int i = 0; int i = 0; i 0 i < a i a i++ i++ i {
            long n = Math.min(arrayA[i], arrayB[i]);
            sum += n;
            arrayA[i] -= n;
            arrayB[i] -= n;
            n = Math.min(arrayA[i + 1], arrayB[i]);
            sum += n;
            arrayA[i + 1] -= n;
            arrayB[i] -= n;
        } {
            long n = Math.min(arrayA[i], arrayB[i]);
            sum += n;
            arrayA[i] -= n;
            arrayB[i] -= n;
            n = Math.min(arrayA[i + 1], arrayB[i]);
            sum += n;
            arrayA[i + 1] -= n;
            arrayB[i] -= n;
        } long n = Math.min(arrayA[i], arrayB[i]); n Math.min(arrayA[i], arrayB[i]) Math.min Math arrayA[i] arrayA i arrayB[i] arrayB i sum += n sum n arrayA[i] -= n arrayA[i] arrayA i n arrayB[i] -= n arrayB[i] arrayB i n n = Math.min(arrayA[i + 1], arrayB[i]) n Math.min(arrayA[i + 1], arrayB[i]) Math.min Math arrayA[i + 1] arrayA i + 1 i 1 arrayB[i] arrayB i sum += n sum n arrayA[i + 1] -= n arrayA[i + 1] arrayA i + 1 i 1 n arrayB[i] -= n arrayB[i] arrayB i n 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 sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] arrayA = new int[a + 1];
        int[] arrayB = new int[a];
        
        for(int i = 0; i < a + 1; i++){
            arrayA[i] = sc.nextInt();
        }
        for(int i = 0; i < a; i++){
            arrayB[i] = sc.nextInt();
        }
        long sum = 0;
        for(int i = 0; i < a; i++){
            long n = Math.min(arrayA[i], arrayB[i]);
            sum += n;
            arrayA[i] -= n;
            arrayB[i] -= n;
            n = Math.min(arrayA[i + 1], arrayB[i]);
            sum += n;
            arrayA[i + 1] -= n;
            arrayB[i] -= n;
        }
        System.out.println(sum);
    }
} public class Main {

	public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] arrayA = new int[a + 1];
        int[] arrayB = new int[a];
        
        for(int i = 0; i < a + 1; i++){
            arrayA[i] = sc.nextInt();
        }
        for(int i = 0; i < a; i++){
            arrayB[i] = sc.nextInt();
        }
        long sum = 0;
        for(int i = 0; i < a; i++){
            long n = Math.min(arrayA[i], arrayB[i]);
            sum += n;
            arrayA[i] -= n;
            arrayB[i] -= n;
            n = Math.min(arrayA[i + 1], arrayB[i]);
            sum += n;
            arrayA[i + 1] -= n;
            arrayB[i] -= n;
        }
        System.out.println(sum);
    }
} Main
import java.util.Scanner;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] arrayA = new int[a + 1];
        int[] arrayB = new int[a];
        
        for(int i = 0; i < a + 1; i++){
            arrayA[i] = sc.nextInt();
        }
        for(int i = 0; i < a; i++){
            arrayB[i] = sc.nextInt();
        }
        long sum = 0;
        for(int i = 0; i < a; i++){
            long n = Math.min(arrayA[i], arrayB[i]);
            sum += n;
            arrayA[i] -= n;
            arrayB[i] -= n;
            n = Math.min(arrayA[i + 1], arrayB[i]);
            sum += n;
            arrayA[i + 1] -= n;
            arrayB[i] -= n;
        }
        System.out.println(sum);
    }
}
