import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        long[] aryA = new long[N+1];
        long[] aryB = new long[N];
        for (int i = 0; i < N+1; i++) {
            long a = Long.parseLong(sc.next());
            aryA[i] = a;
        }
        for (int i = 0; i < N; i++) {
            long a = Long.parseLong(sc.next());
            aryB[i] = a;
        }
        long cnt = 0L;
        for (int i = 0; i < N; i++) {
            long enemyCnt = 0L;
            enemyCnt = (aryA[i] + aryA[i+1]) - aryB[i];
            if (enemyCnt < 0) {
                cnt += aryA[i] + aryA[i+1];
            } else {
                cnt += aryB[i];
            }
            if (aryA[i] < aryB[i]) {
                long sabun = Math.abs(aryA[i] - aryB[i]);
                long after = aryA[i+1] - sabun;
                if (after < 0) {
                    aryA[i + 1] = 0;
                } else {
                    aryA[i + 1] = after;
                }
            }
        }
        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 = Integer.parseInt(sc.next());
        long[] aryA = new long[N+1];
        long[] aryB = new long[N];
        for (int i = 0; i < N+1; i++) {
            long a = Long.parseLong(sc.next());
            aryA[i] = a;
        }
        for (int i = 0; i < N; i++) {
            long a = Long.parseLong(sc.next());
            aryB[i] = a;
        }
        long cnt = 0L;
        for (int i = 0; i < N; i++) {
            long enemyCnt = 0L;
            enemyCnt = (aryA[i] + aryA[i+1]) - aryB[i];
            if (enemyCnt < 0) {
                cnt += aryA[i] + aryA[i+1];
            } else {
                cnt += aryB[i];
            }
            if (aryA[i] < aryB[i]) {
                long sabun = Math.abs(aryA[i] - aryB[i]);
                long after = aryA[i+1] - sabun;
                if (after < 0) {
                    aryA[i + 1] = 0;
                } else {
                    aryA[i + 1] = after;
                }
            }
        }
        System.out.println(cnt);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        long[] aryA = new long[N+1];
        long[] aryB = new long[N];
        for (int i = 0; i < N+1; i++) {
            long a = Long.parseLong(sc.next());
            aryA[i] = a;
        }
        for (int i = 0; i < N; i++) {
            long a = Long.parseLong(sc.next());
            aryB[i] = a;
        }
        long cnt = 0L;
        for (int i = 0; i < N; i++) {
            long enemyCnt = 0L;
            enemyCnt = (aryA[i] + aryA[i+1]) - aryB[i];
            if (enemyCnt < 0) {
                cnt += aryA[i] + aryA[i+1];
            } else {
                cnt += aryB[i];
            }
            if (aryA[i] < aryB[i]) {
                long sabun = Math.abs(aryA[i] - aryB[i]);
                long after = aryA[i+1] - sabun;
                if (after < 0) {
                    aryA[i + 1] = 0;
                } else {
                    aryA[i + 1] = after;
                }
            }
        }
        System.out.println(cnt);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        long[] aryA = new long[N+1];
        long[] aryB = new long[N];
        for (int i = 0; i < N+1; i++) {
            long a = Long.parseLong(sc.next());
            aryA[i] = a;
        }
        for (int i = 0; i < N; i++) {
            long a = Long.parseLong(sc.next());
            aryB[i] = a;
        }
        long cnt = 0L;
        for (int i = 0; i < N; i++) {
            long enemyCnt = 0L;
            enemyCnt = (aryA[i] + aryA[i+1]) - aryB[i];
            if (enemyCnt < 0) {
                cnt += aryA[i] + aryA[i+1];
            } else {
                cnt += aryB[i];
            }
            if (aryA[i] < aryB[i]) {
                long sabun = Math.abs(aryA[i] - aryB[i]);
                long after = aryA[i+1] - sabun;
                if (after < 0) {
                    aryA[i + 1] = 0;
                } else {
                    aryA[i + 1] = after;
                }
            }
        }
        System.out.println(cnt);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc long[] aryA = new long[N+1]; aryA new long[N+1] N+1 N 1 long[] aryB = new long[N]; aryB new long[N] N for (int i = 0; i < N+1; i++) {
            long a = Long.parseLong(sc.next());
            aryA[i] = a;
        } int i = 0; int i = 0; i 0 i < N+1 i N+1 N 1 i++ i++ i {
            long a = Long.parseLong(sc.next());
            aryA[i] = a;
        } {
            long a = Long.parseLong(sc.next());
            aryA[i] = a;
        } long a = Long.parseLong(sc.next()); a Long.parseLong(sc.next()) Long.parseLong Long sc.next() sc.next sc aryA[i] = a aryA[i] aryA i a for (int i = 0; i < N; i++) {
            long a = Long.parseLong(sc.next());
            aryB[i] = a;
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            long a = Long.parseLong(sc.next());
            aryB[i] = a;
        } {
            long a = Long.parseLong(sc.next());
            aryB[i] = a;
        } long a = Long.parseLong(sc.next()); a Long.parseLong(sc.next()) Long.parseLong Long sc.next() sc.next sc aryB[i] = a aryB[i] aryB i a long cnt = 0L; cnt 0L for (int i = 0; i < N; i++) {
            long enemyCnt = 0L;
            enemyCnt = (aryA[i] + aryA[i+1]) - aryB[i];
            if (enemyCnt < 0) {
                cnt += aryA[i] + aryA[i+1];
            } else {
                cnt += aryB[i];
            }
            if (aryA[i] < aryB[i]) {
                long sabun = Math.abs(aryA[i] - aryB[i]);
                long after = aryA[i+1] - sabun;
                if (after < 0) {
                    aryA[i + 1] = 0;
                } else {
                    aryA[i + 1] = after;
                }
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            long enemyCnt = 0L;
            enemyCnt = (aryA[i] + aryA[i+1]) - aryB[i];
            if (enemyCnt < 0) {
                cnt += aryA[i] + aryA[i+1];
            } else {
                cnt += aryB[i];
            }
            if (aryA[i] < aryB[i]) {
                long sabun = Math.abs(aryA[i] - aryB[i]);
                long after = aryA[i+1] - sabun;
                if (after < 0) {
                    aryA[i + 1] = 0;
                } else {
                    aryA[i + 1] = after;
                }
            }
        } {
            long enemyCnt = 0L;
            enemyCnt = (aryA[i] + aryA[i+1]) - aryB[i];
            if (enemyCnt < 0) {
                cnt += aryA[i] + aryA[i+1];
            } else {
                cnt += aryB[i];
            }
            if (aryA[i] < aryB[i]) {
                long sabun = Math.abs(aryA[i] - aryB[i]);
                long after = aryA[i+1] - sabun;
                if (after < 0) {
                    aryA[i + 1] = 0;
                } else {
                    aryA[i + 1] = after;
                }
            }
        } long enemyCnt = 0L; enemyCnt 0L enemyCnt = (aryA[i] + aryA[i+1]) - aryB[i] enemyCnt (aryA[i] + aryA[i+1]) - aryB[i] (aryA[i] + aryA[i+1]) aryA[i] aryA i aryA[i+1] aryA i+1 i 1 aryB[i] aryB i if (enemyCnt < 0) {
                cnt += aryA[i] + aryA[i+1];
            } else {
                cnt += aryB[i];
            } enemyCnt < 0 enemyCnt 0 {
                cnt += aryA[i] + aryA[i+1];
            } cnt += aryA[i] + aryA[i+1] cnt aryA[i] + aryA[i+1] aryA[i] aryA i aryA[i+1] aryA i+1 i 1 {
                cnt += aryB[i];
            } cnt += aryB[i] cnt aryB[i] aryB i if (aryA[i] < aryB[i]) {
                long sabun = Math.abs(aryA[i] - aryB[i]);
                long after = aryA[i+1] - sabun;
                if (after < 0) {
                    aryA[i + 1] = 0;
                } else {
                    aryA[i + 1] = after;
                }
            } aryA[i] < aryB[i] aryA[i] aryA i aryB[i] aryB i {
                long sabun = Math.abs(aryA[i] - aryB[i]);
                long after = aryA[i+1] - sabun;
                if (after < 0) {
                    aryA[i + 1] = 0;
                } else {
                    aryA[i + 1] = after;
                }
            } long sabun = Math.abs(aryA[i] - aryB[i]); sabun Math.abs(aryA[i] - aryB[i]) Math.abs Math aryA[i] - aryB[i] aryA[i] aryA i aryB[i] aryB i long after = aryA[i+1] - sabun; after aryA[i+1] - sabun aryA[i+1] aryA i+1 i 1 sabun if (after < 0) {
                    aryA[i + 1] = 0;
                } else {
                    aryA[i + 1] = after;
                } after < 0 after 0 {
                    aryA[i + 1] = 0;
                } aryA[i + 1] = 0 aryA[i + 1] aryA i + 1 i 1 0 {
                    aryA[i + 1] = after;
                } aryA[i + 1] = after aryA[i + 1] aryA i + 1 i 1 after 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 = Integer.parseInt(sc.next());
        long[] aryA = new long[N+1];
        long[] aryB = new long[N];
        for (int i = 0; i < N+1; i++) {
            long a = Long.parseLong(sc.next());
            aryA[i] = a;
        }
        for (int i = 0; i < N; i++) {
            long a = Long.parseLong(sc.next());
            aryB[i] = a;
        }
        long cnt = 0L;
        for (int i = 0; i < N; i++) {
            long enemyCnt = 0L;
            enemyCnt = (aryA[i] + aryA[i+1]) - aryB[i];
            if (enemyCnt < 0) {
                cnt += aryA[i] + aryA[i+1];
            } else {
                cnt += aryB[i];
            }
            if (aryA[i] < aryB[i]) {
                long sabun = Math.abs(aryA[i] - aryB[i]);
                long after = aryA[i+1] - sabun;
                if (after < 0) {
                    aryA[i + 1] = 0;
                } else {
                    aryA[i + 1] = after;
                }
            }
        }
        System.out.println(cnt);
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        long[] aryA = new long[N+1];
        long[] aryB = new long[N];
        for (int i = 0; i < N+1; i++) {
            long a = Long.parseLong(sc.next());
            aryA[i] = a;
        }
        for (int i = 0; i < N; i++) {
            long a = Long.parseLong(sc.next());
            aryB[i] = a;
        }
        long cnt = 0L;
        for (int i = 0; i < N; i++) {
            long enemyCnt = 0L;
            enemyCnt = (aryA[i] + aryA[i+1]) - aryB[i];
            if (enemyCnt < 0) {
                cnt += aryA[i] + aryA[i+1];
            } else {
                cnt += aryB[i];
            }
            if (aryA[i] < aryB[i]) {
                long sabun = Math.abs(aryA[i] - aryB[i]);
                long after = aryA[i+1] - sabun;
                if (after < 0) {
                    aryA[i + 1] = 0;
                } else {
                    aryA[i + 1] = after;
                }
            }
        }
        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 = Integer.parseInt(sc.next());
        long[] aryA = new long[N+1];
        long[] aryB = new long[N];
        for (int i = 0; i < N+1; i++) {
            long a = Long.parseLong(sc.next());
            aryA[i] = a;
        }
        for (int i = 0; i < N; i++) {
            long a = Long.parseLong(sc.next());
            aryB[i] = a;
        }
        long cnt = 0L;
        for (int i = 0; i < N; i++) {
            long enemyCnt = 0L;
            enemyCnt = (aryA[i] + aryA[i+1]) - aryB[i];
            if (enemyCnt < 0) {
                cnt += aryA[i] + aryA[i+1];
            } else {
                cnt += aryB[i];
            }
            if (aryA[i] < aryB[i]) {
                long sabun = Math.abs(aryA[i] - aryB[i]);
                long after = aryA[i+1] - sabun;
                if (after < 0) {
                    aryA[i + 1] = 0;
                } else {
                    aryA[i + 1] = after;
                }
            }
        }
        System.out.println(cnt);
    }
}