import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        long[] a = new long[n+1];
        for (int i = 0; i < n+1; i++) {
            a[i] = sc.nextLong();
        }

        long cnt = 0;
        for (int i = 0; i < n; i++) {
            long b = sc.nextLong();
            if (b > a[i]) {
                cnt += a[i];
                b -= a[i];
            } else {
                cnt += b;
                b = 0;
            }
            if (b >= a[i+1]) {
                cnt += a[i+1];
                a[i+1] = 0;
            } else {
                cnt += b;
                a[i+1] -= b;
            }
        }

        System.out.println(cnt);
    }
} 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();

        long[] a = new long[n+1];
        for (int i = 0; i < n+1; i++) {
            a[i] = sc.nextLong();
        }

        long cnt = 0;
        for (int i = 0; i < n; i++) {
            long b = sc.nextLong();
            if (b > a[i]) {
                cnt += a[i];
                b -= a[i];
            } else {
                cnt += b;
                b = 0;
            }
            if (b >= a[i+1]) {
                cnt += a[i+1];
                a[i+1] = 0;
            } else {
                cnt += b;
                a[i+1] -= b;
            }
        }

        System.out.println(cnt);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        long[] a = new long[n+1];
        for (int i = 0; i < n+1; i++) {
            a[i] = sc.nextLong();
        }

        long cnt = 0;
        for (int i = 0; i < n; i++) {
            long b = sc.nextLong();
            if (b > a[i]) {
                cnt += a[i];
                b -= a[i];
            } else {
                cnt += b;
                b = 0;
            }
            if (b >= a[i+1]) {
                cnt += a[i+1];
                a[i+1] = 0;
            } else {
                cnt += b;
                a[i+1] -= b;
            }
        }

        System.out.println(cnt);
    } main {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        long[] a = new long[n+1];
        for (int i = 0; i < n+1; i++) {
            a[i] = sc.nextLong();
        }

        long cnt = 0;
        for (int i = 0; i < n; i++) {
            long b = sc.nextLong();
            if (b > a[i]) {
                cnt += a[i];
                b -= a[i];
            } else {
                cnt += b;
                b = 0;
            }
            if (b >= a[i+1]) {
                cnt += a[i+1];
                a[i+1] = 0;
            } else {
                cnt += b;
                a[i+1] -= b;
            }
        }

        System.out.println(cnt);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc long[] a = new long[n+1]; a new long[n+1] n+1 n 1 for (int i = 0; i < n+1; i++) {
            a[i] = sc.nextLong();
        } int i = 0; int i = 0; i 0 i < n+1 i n+1 n 1 i++ i++ i {
            a[i] = sc.nextLong();
        } {
            a[i] = sc.nextLong();
        } a[i] = sc.nextLong() a[i] a i sc.nextLong() sc.nextLong sc long cnt = 0; cnt 0 for (int i = 0; i < n; i++) {
            long b = sc.nextLong();
            if (b > a[i]) {
                cnt += a[i];
                b -= a[i];
            } else {
                cnt += b;
                b = 0;
            }
            if (b >= a[i+1]) {
                cnt += a[i+1];
                a[i+1] = 0;
            } else {
                cnt += b;
                a[i+1] -= b;
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            long b = sc.nextLong();
            if (b > a[i]) {
                cnt += a[i];
                b -= a[i];
            } else {
                cnt += b;
                b = 0;
            }
            if (b >= a[i+1]) {
                cnt += a[i+1];
                a[i+1] = 0;
            } else {
                cnt += b;
                a[i+1] -= b;
            }
        } {
            long b = sc.nextLong();
            if (b > a[i]) {
                cnt += a[i];
                b -= a[i];
            } else {
                cnt += b;
                b = 0;
            }
            if (b >= a[i+1]) {
                cnt += a[i+1];
                a[i+1] = 0;
            } else {
                cnt += b;
                a[i+1] -= b;
            }
        } long b = sc.nextLong(); b sc.nextLong() sc.nextLong sc if (b > a[i]) {
                cnt += a[i];
                b -= a[i];
            } else {
                cnt += b;
                b = 0;
            } b > a[i] b a[i] a i {
                cnt += a[i];
                b -= a[i];
            } cnt += a[i] cnt a[i] a i b -= a[i] b a[i] a i {
                cnt += b;
                b = 0;
            } cnt += b cnt b b = 0 b 0 if (b >= a[i+1]) {
                cnt += a[i+1];
                a[i+1] = 0;
            } else {
                cnt += b;
                a[i+1] -= b;
            } b >= a[i+1] b a[i+1] a i+1 i 1 {
                cnt += a[i+1];
                a[i+1] = 0;
            } cnt += a[i+1] cnt a[i+1] a i+1 i 1 a[i+1] = 0 a[i+1] a i+1 i 1 0 {
                cnt += b;
                a[i+1] -= b;
            } cnt += b cnt b a[i+1] -= b a[i+1] a i+1 i 1 b System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        long[] a = new long[n+1];
        for (int i = 0; i < n+1; i++) {
            a[i] = sc.nextLong();
        }

        long cnt = 0;
        for (int i = 0; i < n; i++) {
            long b = sc.nextLong();
            if (b > a[i]) {
                cnt += a[i];
                b -= a[i];
            } else {
                cnt += b;
                b = 0;
            }
            if (b >= a[i+1]) {
                cnt += a[i+1];
                a[i+1] = 0;
            } else {
                cnt += b;
                a[i+1] -= b;
            }
        }

        System.out.println(cnt);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        long[] a = new long[n+1];
        for (int i = 0; i < n+1; i++) {
            a[i] = sc.nextLong();
        }

        long cnt = 0;
        for (int i = 0; i < n; i++) {
            long b = sc.nextLong();
            if (b > a[i]) {
                cnt += a[i];
                b -= a[i];
            } else {
                cnt += b;
                b = 0;
            }
            if (b >= a[i+1]) {
                cnt += a[i+1];
                a[i+1] = 0;
            } else {
                cnt += b;
                a[i+1] -= b;
            }
        }

        System.out.println(cnt);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        long[] a = new long[n+1];
        for (int i = 0; i < n+1; i++) {
            a[i] = sc.nextLong();
        }

        long cnt = 0;
        for (int i = 0; i < n; i++) {
            long b = sc.nextLong();
            if (b > a[i]) {
                cnt += a[i];
                b -= a[i];
            } else {
                cnt += b;
                b = 0;
            }
            if (b >= a[i+1]) {
                cnt += a[i+1];
                a[i+1] = 0;
            } else {
                cnt += b;
                a[i+1] -= b;
            }
        }

        System.out.println(cnt);
    }
}