

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N+1];
        int[] B = new int[N];
        for(int i = 0; i < N+1; i++) A[i] = sc.nextInt();
        for(int i = 0; i < N; i++) B[i] = sc.nextInt();

        long res = 0;
        for(int i = 0; i < N; i++) {
            int d = Math.min(A[i], B[i]);
            res += d;
            A[i] -= d;
            B[i] -= d;

            d = Math.min(B[i], A[i+1]);
            res += d;
            A[i+1] -= d;
            

        }
        System.out.println(res);
    }
} 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();
        int[] A = new int[N+1];
        int[] B = new int[N];
        for(int i = 0; i < N+1; i++) A[i] = sc.nextInt();
        for(int i = 0; i < N; i++) B[i] = sc.nextInt();

        long res = 0;
        for(int i = 0; i < N; i++) {
            int d = Math.min(A[i], B[i]);
            res += d;
            A[i] -= d;
            B[i] -= d;

            d = Math.min(B[i], A[i+1]);
            res += d;
            A[i+1] -= d;
            

        }
        System.out.println(res);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N+1];
        int[] B = new int[N];
        for(int i = 0; i < N+1; i++) A[i] = sc.nextInt();
        for(int i = 0; i < N; i++) B[i] = sc.nextInt();

        long res = 0;
        for(int i = 0; i < N; i++) {
            int d = Math.min(A[i], B[i]);
            res += d;
            A[i] -= d;
            B[i] -= d;

            d = Math.min(B[i], A[i+1]);
            res += d;
            A[i+1] -= d;
            

        }
        System.out.println(res);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N+1];
        int[] B = new int[N];
        for(int i = 0; i < N+1; i++) A[i] = sc.nextInt();
        for(int i = 0; i < N; i++) B[i] = sc.nextInt();

        long res = 0;
        for(int i = 0; i < N; i++) {
            int d = Math.min(A[i], B[i]);
            res += d;
            A[i] -= d;
            B[i] -= d;

            d = Math.min(B[i], A[i+1]);
            res += d;
            A[i+1] -= d;
            

        }
        System.out.println(res);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] A = new int[N+1]; A new int[N+1] N+1 N 1 int[] B = new int[N]; B new int[N] N for(int i = 0; i < N+1; i++) A[i] = sc.nextInt(); int i = 0; int i = 0; i 0 i < N+1 i N+1 N 1 i++ i++ i A[i] = sc.nextInt(); A[i] = sc.nextInt() A[i] A i sc.nextInt() sc.nextInt sc for(int i = 0; i < N; i++) B[i] = sc.nextInt(); int i = 0; int i = 0; i 0 i < N i N i++ i++ i B[i] = sc.nextInt(); B[i] = sc.nextInt() B[i] B i sc.nextInt() sc.nextInt sc long res = 0; res 0 for(int i = 0; i < N; i++) {
            int d = Math.min(A[i], B[i]);
            res += d;
            A[i] -= d;
            B[i] -= d;

            d = Math.min(B[i], A[i+1]);
            res += d;
            A[i+1] -= d;
            

        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            int d = Math.min(A[i], B[i]);
            res += d;
            A[i] -= d;
            B[i] -= d;

            d = Math.min(B[i], A[i+1]);
            res += d;
            A[i+1] -= d;
            

        } {
            int d = Math.min(A[i], B[i]);
            res += d;
            A[i] -= d;
            B[i] -= d;

            d = Math.min(B[i], A[i+1]);
            res += d;
            A[i+1] -= d;
            

        } int d = Math.min(A[i], B[i]); d Math.min(A[i], B[i]) Math.min Math A[i] A i B[i] B i res += d res d A[i] -= d A[i] A i d B[i] -= d B[i] B i d d = Math.min(B[i], A[i+1]) d Math.min(B[i], A[i+1]) Math.min Math B[i] B i A[i+1] A i+1 i 1 res += d res d A[i+1] -= d A[i+1] A i+1 i 1 d System.out.println(res) System.out.println System.out System System.out res String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N+1];
        int[] B = new int[N];
        for(int i = 0; i < N+1; i++) A[i] = sc.nextInt();
        for(int i = 0; i < N; i++) B[i] = sc.nextInt();

        long res = 0;
        for(int i = 0; i < N; i++) {
            int d = Math.min(A[i], B[i]);
            res += d;
            A[i] -= d;
            B[i] -= d;

            d = Math.min(B[i], A[i+1]);
            res += d;
            A[i+1] -= d;
            

        }
        System.out.println(res);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N+1];
        int[] B = new int[N];
        for(int i = 0; i < N+1; i++) A[i] = sc.nextInt();
        for(int i = 0; i < N; i++) B[i] = sc.nextInt();

        long res = 0;
        for(int i = 0; i < N; i++) {
            int d = Math.min(A[i], B[i]);
            res += d;
            A[i] -= d;
            B[i] -= d;

            d = Math.min(B[i], A[i+1]);
            res += d;
            A[i+1] -= d;
            

        }
        System.out.println(res);
    }
} Main


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N+1];
        int[] B = new int[N];
        for(int i = 0; i < N+1; i++) A[i] = sc.nextInt();
        for(int i = 0; i < N; i++) B[i] = sc.nextInt();

        long res = 0;
        for(int i = 0; i < N; i++) {
            int d = Math.min(A[i], B[i]);
            res += d;
            A[i] -= d;
            B[i] -= d;

            d = Math.min(B[i], A[i+1]);
            res += d;
            A[i+1] -= d;
            

        }
        System.out.println(res);
    }
}
