import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;
    long[] dp;
    long n;
    long S;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N + 1];
        long[] B = new long[N];
        long ans = 0;
        for (int i = 0; i <= N; i++) {
            A[i] = sc.nextLong();
        }
        for (int i = 0; i < N; i++) {
            B[i] = sc.nextLong();
        }
        for (int i = 0; i <= N; i++) {
            if (i == 0) {
                if (B[i] >= A[i]) {
                    ans += A[i];
                    B[i] -= A[i];
                } else {
                    ans += B[i];
                    B[i] = 0;
                }
                continue;
            }
            if (i == N) {
                if (B[i - 1] >= A[i]) {
                    ans += A[i];
                } else {
                    ans += B[i - 1];
                }
                continue;
            }
            A[i] -= B[i - 1];
            if (A[i] < 0) {
                ans += (B[i - 1] + A[i]);
                A[i] = 0;
                continue;
            }
            ans += B[i - 1];
            A[i] -= B[i];
            if (A[i] < 0) {
                ans += (B[i] + A[i]);
                B[i] -= ((B[i] + A[i]));
                A[i] = 0;
                continue;
            }
            ans += B[i];
            B[i] = 0;
        }
        System.out.println(ans);
    }

    int gcd(int m, int n) {
        if (m < n) {
            return gcd(n, m);
        }
        if (n == 0) {
            return m;
        }
        return gcd(n, m % n);
    }
} import java.util.*; util.* java public class Main {

    long INF = Long.MAX_VALUE;
    long[] dp;
    long n;
    long S;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N + 1];
        long[] B = new long[N];
        long ans = 0;
        for (int i = 0; i <= N; i++) {
            A[i] = sc.nextLong();
        }
        for (int i = 0; i < N; i++) {
            B[i] = sc.nextLong();
        }
        for (int i = 0; i <= N; i++) {
            if (i == 0) {
                if (B[i] >= A[i]) {
                    ans += A[i];
                    B[i] -= A[i];
                } else {
                    ans += B[i];
                    B[i] = 0;
                }
                continue;
            }
            if (i == N) {
                if (B[i - 1] >= A[i]) {
                    ans += A[i];
                } else {
                    ans += B[i - 1];
                }
                continue;
            }
            A[i] -= B[i - 1];
            if (A[i] < 0) {
                ans += (B[i - 1] + A[i]);
                A[i] = 0;
                continue;
            }
            ans += B[i - 1];
            A[i] -= B[i];
            if (A[i] < 0) {
                ans += (B[i] + A[i]);
                B[i] -= ((B[i] + A[i]));
                A[i] = 0;
                continue;
            }
            ans += B[i];
            B[i] = 0;
        }
        System.out.println(ans);
    }

    int gcd(int m, int n) {
        if (m < n) {
            return gcd(n, m);
        }
        if (n == 0) {
            return m;
        }
        return gcd(n, m % n);
    }
} Main long INF = Long.MAX_VALUE; INF Long.MAX_VALUE Long Long.MAX_VALUE long[] dp; dp long n; n long S; S public static void main(String[] args) {
        new Main().solve();
    } main {
        new Main().solve();
    } new Main().solve() new Main().solve new Main() String[] args args void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N + 1];
        long[] B = new long[N];
        long ans = 0;
        for (int i = 0; i <= N; i++) {
            A[i] = sc.nextLong();
        }
        for (int i = 0; i < N; i++) {
            B[i] = sc.nextLong();
        }
        for (int i = 0; i <= N; i++) {
            if (i == 0) {
                if (B[i] >= A[i]) {
                    ans += A[i];
                    B[i] -= A[i];
                } else {
                    ans += B[i];
                    B[i] = 0;
                }
                continue;
            }
            if (i == N) {
                if (B[i - 1] >= A[i]) {
                    ans += A[i];
                } else {
                    ans += B[i - 1];
                }
                continue;
            }
            A[i] -= B[i - 1];
            if (A[i] < 0) {
                ans += (B[i - 1] + A[i]);
                A[i] = 0;
                continue;
            }
            ans += B[i - 1];
            A[i] -= B[i];
            if (A[i] < 0) {
                ans += (B[i] + A[i]);
                B[i] -= ((B[i] + A[i]));
                A[i] = 0;
                continue;
            }
            ans += B[i];
            B[i] = 0;
        }
        System.out.println(ans);
    } solve {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N + 1];
        long[] B = new long[N];
        long ans = 0;
        for (int i = 0; i <= N; i++) {
            A[i] = sc.nextLong();
        }
        for (int i = 0; i < N; i++) {
            B[i] = sc.nextLong();
        }
        for (int i = 0; i <= N; i++) {
            if (i == 0) {
                if (B[i] >= A[i]) {
                    ans += A[i];
                    B[i] -= A[i];
                } else {
                    ans += B[i];
                    B[i] = 0;
                }
                continue;
            }
            if (i == N) {
                if (B[i - 1] >= A[i]) {
                    ans += A[i];
                } else {
                    ans += B[i - 1];
                }
                continue;
            }
            A[i] -= B[i - 1];
            if (A[i] < 0) {
                ans += (B[i - 1] + A[i]);
                A[i] = 0;
                continue;
            }
            ans += B[i - 1];
            A[i] -= B[i];
            if (A[i] < 0) {
                ans += (B[i] + A[i]);
                B[i] -= ((B[i] + A[i]));
                A[i] = 0;
                continue;
            }
            ans += B[i];
            B[i] = 0;
        }
        System.out.println(ans);
    } 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 long[] B = new long[N]; B new long[N] N long ans = 0; ans 0 for (int i = 0; i <= N; i++) {
            A[i] = sc.nextLong();
        } int i = 0; int i = 0; i 0 i <= N i N i++ i++ i {
            A[i] = sc.nextLong();
        } {
            A[i] = sc.nextLong();
        } A[i] = sc.nextLong() A[i] A i sc.nextLong() sc.nextLong sc for (int i = 0; i < N; i++) {
            B[i] = sc.nextLong();
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            B[i] = sc.nextLong();
        } {
            B[i] = sc.nextLong();
        } B[i] = sc.nextLong() B[i] B i sc.nextLong() sc.nextLong sc for (int i = 0; i <= N; i++) {
            if (i == 0) {
                if (B[i] >= A[i]) {
                    ans += A[i];
                    B[i] -= A[i];
                } else {
                    ans += B[i];
                    B[i] = 0;
                }
                continue;
            }
            if (i == N) {
                if (B[i - 1] >= A[i]) {
                    ans += A[i];
                } else {
                    ans += B[i - 1];
                }
                continue;
            }
            A[i] -= B[i - 1];
            if (A[i] < 0) {
                ans += (B[i - 1] + A[i]);
                A[i] = 0;
                continue;
            }
            ans += B[i - 1];
            A[i] -= B[i];
            if (A[i] < 0) {
                ans += (B[i] + A[i]);
                B[i] -= ((B[i] + A[i]));
                A[i] = 0;
                continue;
            }
            ans += B[i];
            B[i] = 0;
        } int i = 0; int i = 0; i 0 i <= N i N i++ i++ i {
            if (i == 0) {
                if (B[i] >= A[i]) {
                    ans += A[i];
                    B[i] -= A[i];
                } else {
                    ans += B[i];
                    B[i] = 0;
                }
                continue;
            }
            if (i == N) {
                if (B[i - 1] >= A[i]) {
                    ans += A[i];
                } else {
                    ans += B[i - 1];
                }
                continue;
            }
            A[i] -= B[i - 1];
            if (A[i] < 0) {
                ans += (B[i - 1] + A[i]);
                A[i] = 0;
                continue;
            }
            ans += B[i - 1];
            A[i] -= B[i];
            if (A[i] < 0) {
                ans += (B[i] + A[i]);
                B[i] -= ((B[i] + A[i]));
                A[i] = 0;
                continue;
            }
            ans += B[i];
            B[i] = 0;
        } {
            if (i == 0) {
                if (B[i] >= A[i]) {
                    ans += A[i];
                    B[i] -= A[i];
                } else {
                    ans += B[i];
                    B[i] = 0;
                }
                continue;
            }
            if (i == N) {
                if (B[i - 1] >= A[i]) {
                    ans += A[i];
                } else {
                    ans += B[i - 1];
                }
                continue;
            }
            A[i] -= B[i - 1];
            if (A[i] < 0) {
                ans += (B[i - 1] + A[i]);
                A[i] = 0;
                continue;
            }
            ans += B[i - 1];
            A[i] -= B[i];
            if (A[i] < 0) {
                ans += (B[i] + A[i]);
                B[i] -= ((B[i] + A[i]));
                A[i] = 0;
                continue;
            }
            ans += B[i];
            B[i] = 0;
        } if (i == 0) {
                if (B[i] >= A[i]) {
                    ans += A[i];
                    B[i] -= A[i];
                } else {
                    ans += B[i];
                    B[i] = 0;
                }
                continue;
            } i == 0 i 0 {
                if (B[i] >= A[i]) {
                    ans += A[i];
                    B[i] -= A[i];
                } else {
                    ans += B[i];
                    B[i] = 0;
                }
                continue;
            } if (B[i] >= A[i]) {
                    ans += A[i];
                    B[i] -= A[i];
                } else {
                    ans += B[i];
                    B[i] = 0;
                } B[i] >= A[i] B[i] B i A[i] A i {
                    ans += A[i];
                    B[i] -= A[i];
                } ans += A[i] ans A[i] A i B[i] -= A[i] B[i] B i A[i] A i {
                    ans += B[i];
                    B[i] = 0;
                } ans += B[i] ans B[i] B i B[i] = 0 B[i] B i 0 continue; if (i == N) {
                if (B[i - 1] >= A[i]) {
                    ans += A[i];
                } else {
                    ans += B[i - 1];
                }
                continue;
            } i == N i N {
                if (B[i - 1] >= A[i]) {
                    ans += A[i];
                } else {
                    ans += B[i - 1];
                }
                continue;
            } if (B[i - 1] >= A[i]) {
                    ans += A[i];
                } else {
                    ans += B[i - 1];
                } B[i - 1] >= A[i] B[i - 1] B i - 1 i 1 A[i] A i {
                    ans += A[i];
                } ans += A[i] ans A[i] A i {
                    ans += B[i - 1];
                } ans += B[i - 1] ans B[i - 1] B i - 1 i 1 continue; A[i] -= B[i - 1] A[i] A i B[i - 1] B i - 1 i 1 if (A[i] < 0) {
                ans += (B[i - 1] + A[i]);
                A[i] = 0;
                continue;
            } A[i] < 0 A[i] A i 0 {
                ans += (B[i - 1] + A[i]);
                A[i] = 0;
                continue;
            } ans += (B[i - 1] + A[i]) ans (B[i - 1] + A[i]) B[i - 1] B i - 1 i 1 A[i] A i A[i] = 0 A[i] A i 0 continue; ans += B[i - 1] ans B[i - 1] B i - 1 i 1 A[i] -= B[i] A[i] A i B[i] B i if (A[i] < 0) {
                ans += (B[i] + A[i]);
                B[i] -= ((B[i] + A[i]));
                A[i] = 0;
                continue;
            } A[i] < 0 A[i] A i 0 {
                ans += (B[i] + A[i]);
                B[i] -= ((B[i] + A[i]));
                A[i] = 0;
                continue;
            } ans += (B[i] + A[i]) ans (B[i] + A[i]) B[i] B i A[i] A i B[i] -= ((B[i] + A[i])) B[i] B i ((B[i] + A[i])) B[i] B i A[i] A i A[i] = 0 A[i] A i 0 continue; ans += B[i] ans B[i] B i B[i] = 0 B[i] B i 0 System.out.println(ans) System.out.println System.out System System.out ans int gcd(int m, int n) {
        if (m < n) {
            return gcd(n, m);
        }
        if (n == 0) {
            return m;
        }
        return gcd(n, m % n);
    } gcd {
        if (m < n) {
            return gcd(n, m);
        }
        if (n == 0) {
            return m;
        }
        return gcd(n, m % n);
    } if (m < n) {
            return gcd(n, m);
        } m < n m n {
            return gcd(n, m);
        } return gcd(n, m); gcd(n, m) gcd n m if (n == 0) {
            return m;
        } n == 0 n 0 {
            return m;
        } return m; m return gcd(n, m % n); gcd(n, m % n) gcd n m % n m n int m m int n n public class Main {

    long INF = Long.MAX_VALUE;
    long[] dp;
    long n;
    long S;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N + 1];
        long[] B = new long[N];
        long ans = 0;
        for (int i = 0; i <= N; i++) {
            A[i] = sc.nextLong();
        }
        for (int i = 0; i < N; i++) {
            B[i] = sc.nextLong();
        }
        for (int i = 0; i <= N; i++) {
            if (i == 0) {
                if (B[i] >= A[i]) {
                    ans += A[i];
                    B[i] -= A[i];
                } else {
                    ans += B[i];
                    B[i] = 0;
                }
                continue;
            }
            if (i == N) {
                if (B[i - 1] >= A[i]) {
                    ans += A[i];
                } else {
                    ans += B[i - 1];
                }
                continue;
            }
            A[i] -= B[i - 1];
            if (A[i] < 0) {
                ans += (B[i - 1] + A[i]);
                A[i] = 0;
                continue;
            }
            ans += B[i - 1];
            A[i] -= B[i];
            if (A[i] < 0) {
                ans += (B[i] + A[i]);
                B[i] -= ((B[i] + A[i]));
                A[i] = 0;
                continue;
            }
            ans += B[i];
            B[i] = 0;
        }
        System.out.println(ans);
    }

    int gcd(int m, int n) {
        if (m < n) {
            return gcd(n, m);
        }
        if (n == 0) {
            return m;
        }
        return gcd(n, m % n);
    }
} public class Main {

    long INF = Long.MAX_VALUE;
    long[] dp;
    long n;
    long S;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N + 1];
        long[] B = new long[N];
        long ans = 0;
        for (int i = 0; i <= N; i++) {
            A[i] = sc.nextLong();
        }
        for (int i = 0; i < N; i++) {
            B[i] = sc.nextLong();
        }
        for (int i = 0; i <= N; i++) {
            if (i == 0) {
                if (B[i] >= A[i]) {
                    ans += A[i];
                    B[i] -= A[i];
                } else {
                    ans += B[i];
                    B[i] = 0;
                }
                continue;
            }
            if (i == N) {
                if (B[i - 1] >= A[i]) {
                    ans += A[i];
                } else {
                    ans += B[i - 1];
                }
                continue;
            }
            A[i] -= B[i - 1];
            if (A[i] < 0) {
                ans += (B[i - 1] + A[i]);
                A[i] = 0;
                continue;
            }
            ans += B[i - 1];
            A[i] -= B[i];
            if (A[i] < 0) {
                ans += (B[i] + A[i]);
                B[i] -= ((B[i] + A[i]));
                A[i] = 0;
                continue;
            }
            ans += B[i];
            B[i] = 0;
        }
        System.out.println(ans);
    }

    int gcd(int m, int n) {
        if (m < n) {
            return gcd(n, m);
        }
        if (n == 0) {
            return m;
        }
        return gcd(n, m % n);
    }
} Main
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;
    long[] dp;
    long n;
    long S;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N + 1];
        long[] B = new long[N];
        long ans = 0;
        for (int i = 0; i <= N; i++) {
            A[i] = sc.nextLong();
        }
        for (int i = 0; i < N; i++) {
            B[i] = sc.nextLong();
        }
        for (int i = 0; i <= N; i++) {
            if (i == 0) {
                if (B[i] >= A[i]) {
                    ans += A[i];
                    B[i] -= A[i];
                } else {
                    ans += B[i];
                    B[i] = 0;
                }
                continue;
            }
            if (i == N) {
                if (B[i - 1] >= A[i]) {
                    ans += A[i];
                } else {
                    ans += B[i - 1];
                }
                continue;
            }
            A[i] -= B[i - 1];
            if (A[i] < 0) {
                ans += (B[i - 1] + A[i]);
                A[i] = 0;
                continue;
            }
            ans += B[i - 1];
            A[i] -= B[i];
            if (A[i] < 0) {
                ans += (B[i] + A[i]);
                B[i] -= ((B[i] + A[i]));
                A[i] = 0;
                continue;
            }
            ans += B[i];
            B[i] = 0;
        }
        System.out.println(ans);
    }

    int gcd(int m, int n) {
        if (m < n) {
            return gcd(n, m);
        }
        if (n == 0) {
            return m;
        }
        return gcd(n, m % n);
    }
}
