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