import java.util.Scanner;
 
class Main {
    public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n+1];
        int[] b = new int[n];
        for (int i = 0; i < n + 1; i++) {
            a[i] = scan.nextInt();
        }
        for (int i = 0; i < n; i++) {
            b[i] = scan.nextInt();
        }
        long ans = 0;
        for (int j = 0; j < n; j++) {
            int x = Math.min(a[j], b[j]);
            ans += x;
            b[j] -= x;
            int y = Math.min(a[j + 1], b[j]);
            ans += y;
            a[j + 1] -= y;
        }
        System.out.println(ans);
    }
} import java.util.Scanner; Scanner java.util class Main {
    public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n+1];
        int[] b = new int[n];
        for (int i = 0; i < n + 1; i++) {
            a[i] = scan.nextInt();
        }
        for (int i = 0; i < n; i++) {
            b[i] = scan.nextInt();
        }
        long ans = 0;
        for (int j = 0; j < n; j++) {
            int x = Math.min(a[j], b[j]);
            ans += x;
            b[j] -= x;
            int y = Math.min(a[j + 1], b[j]);
            ans += y;
            a[j + 1] -= y;
        }
        System.out.println(ans);
    }
} Main public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n+1];
        int[] b = new int[n];
        for (int i = 0; i < n + 1; i++) {
            a[i] = scan.nextInt();
        }
        for (int i = 0; i < n; i++) {
            b[i] = scan.nextInt();
        }
        long ans = 0;
        for (int j = 0; j < n; j++) {
            int x = Math.min(a[j], b[j]);
            ans += x;
            b[j] -= x;
            int y = Math.min(a[j + 1], b[j]);
            ans += y;
            a[j + 1] -= y;
        }
        System.out.println(ans);
    } main {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n+1];
        int[] b = new int[n];
        for (int i = 0; i < n + 1; i++) {
            a[i] = scan.nextInt();
        }
        for (int i = 0; i < n; i++) {
            b[i] = scan.nextInt();
        }
        long ans = 0;
        for (int j = 0; j < n; j++) {
            int x = Math.min(a[j], b[j]);
            ans += x;
            b[j] -= x;
            int y = Math.min(a[j + 1], b[j]);
            ans += y;
            a[j + 1] -= y;
        }
        System.out.println(ans);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan 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] = scan.nextInt();
        } int i = 0; int i = 0; i 0 i < n + 1 i n + 1 n 1 i++ i++ i {
            a[i] = scan.nextInt();
        } {
            a[i] = scan.nextInt();
        } a[i] = scan.nextInt() a[i] a i scan.nextInt() scan.nextInt scan for (int i = 0; i < n; i++) {
            b[i] = scan.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            b[i] = scan.nextInt();
        } {
            b[i] = scan.nextInt();
        } b[i] = scan.nextInt() b[i] b i scan.nextInt() scan.nextInt scan long ans = 0; ans 0 for (int j = 0; j < n; j++) {
            int x = Math.min(a[j], b[j]);
            ans += x;
            b[j] -= x;
            int y = Math.min(a[j + 1], b[j]);
            ans += y;
            a[j + 1] -= y;
        } int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
            int x = Math.min(a[j], b[j]);
            ans += x;
            b[j] -= x;
            int y = Math.min(a[j + 1], b[j]);
            ans += y;
            a[j + 1] -= y;
        } {
            int x = Math.min(a[j], b[j]);
            ans += x;
            b[j] -= x;
            int y = Math.min(a[j + 1], b[j]);
            ans += y;
            a[j + 1] -= y;
        } int x = Math.min(a[j], b[j]); x Math.min(a[j], b[j]) Math.min Math a[j] a j b[j] b j ans += x ans x b[j] -= x b[j] b j x int y = Math.min(a[j + 1], b[j]); y Math.min(a[j + 1], b[j]) Math.min Math a[j + 1] a j + 1 j 1 b[j] b j ans += y ans y a[j + 1] -= y a[j + 1] a j + 1 j 1 y System.out.println(ans) System.out.println System.out System System.out ans final String[] args args
import java.util.Scanner;
 
class Main {
    public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n+1];
        int[] b = new int[n];
        for (int i = 0; i < n + 1; i++) {
            a[i] = scan.nextInt();
        }
        for (int i = 0; i < n; i++) {
            b[i] = scan.nextInt();
        }
        long ans = 0;
        for (int j = 0; j < n; j++) {
            int x = Math.min(a[j], b[j]);
            ans += x;
            b[j] -= x;
            int y = Math.min(a[j + 1], b[j]);
            ans += y;
            a[j + 1] -= y;
        }
        System.out.println(ans);
    }
}