import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Main main = new Main();
        main.solve();
    }
    public void solve() throws Exception {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long[] a_f = new long[N + 1];
        long[] a_b = new long[N + 1];
        for (int i = 0; i < N + 1; i++) {
            a_f[i] = scan.nextLong();
            a_b[i] = a_f[i];
        }
        long[] b = new long[N + 1];
        for (int i = 0; i < N; i++) {
            b[i] = scan.nextLong();
        }
        long answer = front(N, a_f, b);
        answer = Math.max(answer,back(N, a_b, b));
        System.out.println(answer);
    }
    private long front(int N, long[] a, long[] b) {
        long answer = 0;
        for (int i = 0; i < N; i++) {
            answer += Math.min(b[i],a[i]);
            long t = Math.max(0, b[i]-a[i]);
            answer += Math.min(a[i+1], t);
            a[i+1] = Math.max(0, a[i+1]-t);
        }
        return answer;
    }
    private long back(int N, long[] a, long[] b) {
        long answer = 0;
        for (int i = N-1; 0 <= i; i--) {
            answer += Math.min(b[i],a[i+1]);
            long t = Math.max(0, b[i]-a[i+1]);
            answer += Math.min(a[i], t);
            a[i] = Math.max(0, a[i]-t);
        }
        return answer;
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) throws Exception {
        Main main = new Main();
        main.solve();
    }
    public void solve() throws Exception {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long[] a_f = new long[N + 1];
        long[] a_b = new long[N + 1];
        for (int i = 0; i < N + 1; i++) {
            a_f[i] = scan.nextLong();
            a_b[i] = a_f[i];
        }
        long[] b = new long[N + 1];
        for (int i = 0; i < N; i++) {
            b[i] = scan.nextLong();
        }
        long answer = front(N, a_f, b);
        answer = Math.max(answer,back(N, a_b, b));
        System.out.println(answer);
    }
    private long front(int N, long[] a, long[] b) {
        long answer = 0;
        for (int i = 0; i < N; i++) {
            answer += Math.min(b[i],a[i]);
            long t = Math.max(0, b[i]-a[i]);
            answer += Math.min(a[i+1], t);
            a[i+1] = Math.max(0, a[i+1]-t);
        }
        return answer;
    }
    private long back(int N, long[] a, long[] b) {
        long answer = 0;
        for (int i = N-1; 0 <= i; i--) {
            answer += Math.min(b[i],a[i+1]);
            long t = Math.max(0, b[i]-a[i+1]);
            answer += Math.min(a[i], t);
            a[i] = Math.max(0, a[i]-t);
        }
        return answer;
    }
} Main public static void main(String[] args) throws Exception {
        Main main = new Main();
        main.solve();
    } main {
        Main main = new Main();
        main.solve();
    } Main main = new Main(); main new Main() main.solve() main.solve main String[] args args public void solve() throws Exception {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long[] a_f = new long[N + 1];
        long[] a_b = new long[N + 1];
        for (int i = 0; i < N + 1; i++) {
            a_f[i] = scan.nextLong();
            a_b[i] = a_f[i];
        }
        long[] b = new long[N + 1];
        for (int i = 0; i < N; i++) {
            b[i] = scan.nextLong();
        }
        long answer = front(N, a_f, b);
        answer = Math.max(answer,back(N, a_b, b));
        System.out.println(answer);
    } solve {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long[] a_f = new long[N + 1];
        long[] a_b = new long[N + 1];
        for (int i = 0; i < N + 1; i++) {
            a_f[i] = scan.nextLong();
            a_b[i] = a_f[i];
        }
        long[] b = new long[N + 1];
        for (int i = 0; i < N; i++) {
            b[i] = scan.nextLong();
        }
        long answer = front(N, a_f, b);
        answer = Math.max(answer,back(N, a_b, b));
        System.out.println(answer);
    } Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in))); scan new Scanner(new BufferedReader(new InputStreamReader(System.in))) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan long[] a_f = new long[N + 1]; a_f new long[N + 1] N + 1 N 1 long[] a_b = new long[N + 1]; a_b new long[N + 1] N + 1 N 1 for (int i = 0; i < N + 1; i++) {
            a_f[i] = scan.nextLong();
            a_b[i] = a_f[i];
        } int i = 0; int i = 0; i 0 i < N + 1 i N + 1 N 1 i++ i++ i {
            a_f[i] = scan.nextLong();
            a_b[i] = a_f[i];
        } {
            a_f[i] = scan.nextLong();
            a_b[i] = a_f[i];
        } a_f[i] = scan.nextLong() a_f[i] a_f i scan.nextLong() scan.nextLong scan a_b[i] = a_f[i] a_b[i] a_b i a_f[i] a_f i long[] b = new long[N + 1]; b new long[N + 1] N + 1 N 1 for (int i = 0; i < N; i++) {
            b[i] = scan.nextLong();
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            b[i] = scan.nextLong();
        } {
            b[i] = scan.nextLong();
        } b[i] = scan.nextLong() b[i] b i scan.nextLong() scan.nextLong scan long answer = front(N, a_f, b); answer front(N, a_f, b) front N a_f b answer = Math.max(answer,back(N, a_b, b)) answer Math.max(answer,back(N, a_b, b)) Math.max Math answer back(N, a_b, b) back N a_b b System.out.println(answer) System.out.println System.out System System.out answer private long front(int N, long[] a, long[] b) {
        long answer = 0;
        for (int i = 0; i < N; i++) {
            answer += Math.min(b[i],a[i]);
            long t = Math.max(0, b[i]-a[i]);
            answer += Math.min(a[i+1], t);
            a[i+1] = Math.max(0, a[i+1]-t);
        }
        return answer;
    } front {
        long answer = 0;
        for (int i = 0; i < N; i++) {
            answer += Math.min(b[i],a[i]);
            long t = Math.max(0, b[i]-a[i]);
            answer += Math.min(a[i+1], t);
            a[i+1] = Math.max(0, a[i+1]-t);
        }
        return answer;
    } long answer = 0; answer 0 for (int i = 0; i < N; i++) {
            answer += Math.min(b[i],a[i]);
            long t = Math.max(0, b[i]-a[i]);
            answer += Math.min(a[i+1], t);
            a[i+1] = Math.max(0, a[i+1]-t);
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            answer += Math.min(b[i],a[i]);
            long t = Math.max(0, b[i]-a[i]);
            answer += Math.min(a[i+1], t);
            a[i+1] = Math.max(0, a[i+1]-t);
        } {
            answer += Math.min(b[i],a[i]);
            long t = Math.max(0, b[i]-a[i]);
            answer += Math.min(a[i+1], t);
            a[i+1] = Math.max(0, a[i+1]-t);
        } answer += Math.min(b[i],a[i]) answer Math.min(b[i],a[i]) Math.min Math b[i] b i a[i] a i long t = Math.max(0, b[i]-a[i]); t Math.max(0, b[i]-a[i]) Math.max Math 0 b[i]-a[i] b[i] b i a[i] a i answer += Math.min(a[i+1], t) answer Math.min(a[i+1], t) Math.min Math a[i+1] a i+1 i 1 t a[i+1] = Math.max(0, a[i+1]-t) a[i+1] a i+1 i 1 Math.max(0, a[i+1]-t) Math.max Math 0 a[i+1]-t a[i+1] a i+1 i 1 t return answer; answer int N N long[] a a long[] b b private long back(int N, long[] a, long[] b) {
        long answer = 0;
        for (int i = N-1; 0 <= i; i--) {
            answer += Math.min(b[i],a[i+1]);
            long t = Math.max(0, b[i]-a[i+1]);
            answer += Math.min(a[i], t);
            a[i] = Math.max(0, a[i]-t);
        }
        return answer;
    } back {
        long answer = 0;
        for (int i = N-1; 0 <= i; i--) {
            answer += Math.min(b[i],a[i+1]);
            long t = Math.max(0, b[i]-a[i+1]);
            answer += Math.min(a[i], t);
            a[i] = Math.max(0, a[i]-t);
        }
        return answer;
    } long answer = 0; answer 0 for (int i = N-1; 0 <= i; i--) {
            answer += Math.min(b[i],a[i+1]);
            long t = Math.max(0, b[i]-a[i+1]);
            answer += Math.min(a[i], t);
            a[i] = Math.max(0, a[i]-t);
        } int i = N-1; int i = N-1; i N-1 N 1 0 <= i 0 i i-- i-- i {
            answer += Math.min(b[i],a[i+1]);
            long t = Math.max(0, b[i]-a[i+1]);
            answer += Math.min(a[i], t);
            a[i] = Math.max(0, a[i]-t);
        } {
            answer += Math.min(b[i],a[i+1]);
            long t = Math.max(0, b[i]-a[i+1]);
            answer += Math.min(a[i], t);
            a[i] = Math.max(0, a[i]-t);
        } answer += Math.min(b[i],a[i+1]) answer Math.min(b[i],a[i+1]) Math.min Math b[i] b i a[i+1] a i+1 i 1 long t = Math.max(0, b[i]-a[i+1]); t Math.max(0, b[i]-a[i+1]) Math.max Math 0 b[i]-a[i+1] b[i] b i a[i+1] a i+1 i 1 answer += Math.min(a[i], t) answer Math.min(a[i], t) Math.min Math a[i] a i t a[i] = Math.max(0, a[i]-t) a[i] a i Math.max(0, a[i]-t) Math.max Math 0 a[i]-t a[i] a i t return answer; answer int N N long[] a a long[] b b public class Main {
    public static void main(String[] args) throws Exception {
        Main main = new Main();
        main.solve();
    }
    public void solve() throws Exception {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long[] a_f = new long[N + 1];
        long[] a_b = new long[N + 1];
        for (int i = 0; i < N + 1; i++) {
            a_f[i] = scan.nextLong();
            a_b[i] = a_f[i];
        }
        long[] b = new long[N + 1];
        for (int i = 0; i < N; i++) {
            b[i] = scan.nextLong();
        }
        long answer = front(N, a_f, b);
        answer = Math.max(answer,back(N, a_b, b));
        System.out.println(answer);
    }
    private long front(int N, long[] a, long[] b) {
        long answer = 0;
        for (int i = 0; i < N; i++) {
            answer += Math.min(b[i],a[i]);
            long t = Math.max(0, b[i]-a[i]);
            answer += Math.min(a[i+1], t);
            a[i+1] = Math.max(0, a[i+1]-t);
        }
        return answer;
    }
    private long back(int N, long[] a, long[] b) {
        long answer = 0;
        for (int i = N-1; 0 <= i; i--) {
            answer += Math.min(b[i],a[i+1]);
            long t = Math.max(0, b[i]-a[i+1]);
            answer += Math.min(a[i], t);
            a[i] = Math.max(0, a[i]-t);
        }
        return answer;
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Main main = new Main();
        main.solve();
    }
    public void solve() throws Exception {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long[] a_f = new long[N + 1];
        long[] a_b = new long[N + 1];
        for (int i = 0; i < N + 1; i++) {
            a_f[i] = scan.nextLong();
            a_b[i] = a_f[i];
        }
        long[] b = new long[N + 1];
        for (int i = 0; i < N; i++) {
            b[i] = scan.nextLong();
        }
        long answer = front(N, a_f, b);
        answer = Math.max(answer,back(N, a_b, b));
        System.out.println(answer);
    }
    private long front(int N, long[] a, long[] b) {
        long answer = 0;
        for (int i = 0; i < N; i++) {
            answer += Math.min(b[i],a[i]);
            long t = Math.max(0, b[i]-a[i]);
            answer += Math.min(a[i+1], t);
            a[i+1] = Math.max(0, a[i+1]-t);
        }
        return answer;
    }
    private long back(int N, long[] a, long[] b) {
        long answer = 0;
        for (int i = N-1; 0 <= i; i--) {
            answer += Math.min(b[i],a[i+1]);
            long t = Math.max(0, b[i]-a[i+1]);
            answer += Math.min(a[i], t);
            a[i] = Math.max(0, a[i]-t);
        }
        return answer;
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Main main = new Main();
        main.solve();
    }
    public void solve() throws Exception {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long[] a_f = new long[N + 1];
        long[] a_b = new long[N + 1];
        for (int i = 0; i < N + 1; i++) {
            a_f[i] = scan.nextLong();
            a_b[i] = a_f[i];
        }
        long[] b = new long[N + 1];
        for (int i = 0; i < N; i++) {
            b[i] = scan.nextLong();
        }
        long answer = front(N, a_f, b);
        answer = Math.max(answer,back(N, a_b, b));
        System.out.println(answer);
    }
    private long front(int N, long[] a, long[] b) {
        long answer = 0;
        for (int i = 0; i < N; i++) {
            answer += Math.min(b[i],a[i]);
            long t = Math.max(0, b[i]-a[i]);
            answer += Math.min(a[i+1], t);
            a[i+1] = Math.max(0, a[i+1]-t);
        }
        return answer;
    }
    private long back(int N, long[] a, long[] b) {
        long answer = 0;
        for (int i = N-1; 0 <= i; i--) {
            answer += Math.min(b[i],a[i+1]);
            long t = Math.max(0, b[i]-a[i+1]);
            answer += Math.min(a[i], t);
            a[i] = Math.max(0, a[i]-t);
        }
        return answer;
    }
}
