import java.util.*;

class Main {
    public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] an = new int[n + 1];
        int[] bn = new int[n];
        for (int i = 0; i < n + 1; i++) {
            an[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            bn[i] = sc.nextInt();
        }
        sc.close();

        long count = 0;
        for (int i = 0; i < n; i++) {
            if (an[i] >= bn[i]) {
                count += bn[i];
                continue;
            } else {
                count += an[i];
                bn[i] = bn[i] - an[i];
            }
            if (an[i + 1] > bn[i]) {
                count += bn[i];
                an[i + 1] = an[i + 1] - bn[i];
            } else {
                count += an[i + 1];
                an[i + 1] = 0;
            }
        }
        System.out.println(count);
    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] an = new int[n + 1];
        int[] bn = new int[n];
        for (int i = 0; i < n + 1; i++) {
            an[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            bn[i] = sc.nextInt();
        }
        sc.close();

        long count = 0;
        for (int i = 0; i < n; i++) {
            if (an[i] >= bn[i]) {
                count += bn[i];
                continue;
            } else {
                count += an[i];
                bn[i] = bn[i] - an[i];
            }
            if (an[i + 1] > bn[i]) {
                count += bn[i];
                an[i + 1] = an[i + 1] - bn[i];
            } else {
                count += an[i + 1];
                an[i + 1] = 0;
            }
        }
        System.out.println(count);
    }
} Main public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] an = new int[n + 1];
        int[] bn = new int[n];
        for (int i = 0; i < n + 1; i++) {
            an[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            bn[i] = sc.nextInt();
        }
        sc.close();

        long count = 0;
        for (int i = 0; i < n; i++) {
            if (an[i] >= bn[i]) {
                count += bn[i];
                continue;
            } else {
                count += an[i];
                bn[i] = bn[i] - an[i];
            }
            if (an[i + 1] > bn[i]) {
                count += bn[i];
                an[i + 1] = an[i + 1] - bn[i];
            } else {
                count += an[i + 1];
                an[i + 1] = 0;
            }
        }
        System.out.println(count);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] an = new int[n + 1];
        int[] bn = new int[n];
        for (int i = 0; i < n + 1; i++) {
            an[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            bn[i] = sc.nextInt();
        }
        sc.close();

        long count = 0;
        for (int i = 0; i < n; i++) {
            if (an[i] >= bn[i]) {
                count += bn[i];
                continue;
            } else {
                count += an[i];
                bn[i] = bn[i] - an[i];
            }
            if (an[i + 1] > bn[i]) {
                count += bn[i];
                an[i + 1] = an[i + 1] - bn[i];
            } else {
                count += an[i + 1];
                an[i + 1] = 0;
            }
        }
        System.out.println(count);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] an = new int[n + 1]; an new int[n + 1] n + 1 n 1 int[] bn = new int[n]; bn new int[n] n for (int i = 0; i < n + 1; i++) {
            an[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < n + 1 i n + 1 n 1 i++ i++ i {
            an[i] = sc.nextInt();
        } {
            an[i] = sc.nextInt();
        } an[i] = sc.nextInt() an[i] an i sc.nextInt() sc.nextInt sc for (int i = 0; i < n; i++) {
            bn[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            bn[i] = sc.nextInt();
        } {
            bn[i] = sc.nextInt();
        } bn[i] = sc.nextInt() bn[i] bn i sc.nextInt() sc.nextInt sc sc.close() sc.close sc long count = 0; count 0 for (int i = 0; i < n; i++) {
            if (an[i] >= bn[i]) {
                count += bn[i];
                continue;
            } else {
                count += an[i];
                bn[i] = bn[i] - an[i];
            }
            if (an[i + 1] > bn[i]) {
                count += bn[i];
                an[i + 1] = an[i + 1] - bn[i];
            } else {
                count += an[i + 1];
                an[i + 1] = 0;
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            if (an[i] >= bn[i]) {
                count += bn[i];
                continue;
            } else {
                count += an[i];
                bn[i] = bn[i] - an[i];
            }
            if (an[i + 1] > bn[i]) {
                count += bn[i];
                an[i + 1] = an[i + 1] - bn[i];
            } else {
                count += an[i + 1];
                an[i + 1] = 0;
            }
        } {
            if (an[i] >= bn[i]) {
                count += bn[i];
                continue;
            } else {
                count += an[i];
                bn[i] = bn[i] - an[i];
            }
            if (an[i + 1] > bn[i]) {
                count += bn[i];
                an[i + 1] = an[i + 1] - bn[i];
            } else {
                count += an[i + 1];
                an[i + 1] = 0;
            }
        } if (an[i] >= bn[i]) {
                count += bn[i];
                continue;
            } else {
                count += an[i];
                bn[i] = bn[i] - an[i];
            } an[i] >= bn[i] an[i] an i bn[i] bn i {
                count += bn[i];
                continue;
            } count += bn[i] count bn[i] bn i continue; {
                count += an[i];
                bn[i] = bn[i] - an[i];
            } count += an[i] count an[i] an i bn[i] = bn[i] - an[i] bn[i] bn i bn[i] - an[i] bn[i] bn i an[i] an i if (an[i + 1] > bn[i]) {
                count += bn[i];
                an[i + 1] = an[i + 1] - bn[i];
            } else {
                count += an[i + 1];
                an[i + 1] = 0;
            } an[i + 1] > bn[i] an[i + 1] an i + 1 i 1 bn[i] bn i {
                count += bn[i];
                an[i + 1] = an[i + 1] - bn[i];
            } count += bn[i] count bn[i] bn i an[i + 1] = an[i + 1] - bn[i] an[i + 1] an i + 1 i 1 an[i + 1] - bn[i] an[i + 1] an i + 1 i 1 bn[i] bn i {
                count += an[i + 1];
                an[i + 1] = 0;
            } count += an[i + 1] count an[i + 1] an i + 1 i 1 an[i + 1] = 0 an[i + 1] an i + 1 i 1 0 System.out.println(count) System.out.println System.out System System.out count String[] args args
import java.util.*;

class Main {
    public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] an = new int[n + 1];
        int[] bn = new int[n];
        for (int i = 0; i < n + 1; i++) {
            an[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            bn[i] = sc.nextInt();
        }
        sc.close();

        long count = 0;
        for (int i = 0; i < n; i++) {
            if (an[i] >= bn[i]) {
                count += bn[i];
                continue;
            } else {
                count += an[i];
                bn[i] = bn[i] - an[i];
            }
            if (an[i + 1] > bn[i]) {
                count += bn[i];
                an[i + 1] = an[i + 1] - bn[i];
            } else {
                count += an[i + 1];
                an[i + 1] = 0;
            }
        }
        System.out.println(count);
    }
}
