import java.io.*;

/**
 * Created by Ayushi on 27/07/2019.
 */

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        String[] temp = r.readLine().split(" ");
        int n = Integer.parseInt(temp[0]);
        temp = r.readLine().split(" ");
        long[] t = new long[n+1];
        for (int i = 0; i < n+1; i++) {
            t[i] = Long.parseLong(temp[i]);
        }
        temp = r.readLine().split(" ");
        long[] s = new long[n];
        for (int j = 0; j < n; j++) {
            s[j] = Long.parseLong(temp[j]);
        }
        r.close();

        long d = 0;
        long x;
        for (int k = 0; k < n; k++) {
            for (int l = 0; l < 2; l++) {
                x = Math.min(t[k + l], s[k]);
                t[k + l] = t[k + l] - x;
                s[k] = s[k] - x;
                d += x;
            }
        }
        System.out.println(d);
    }
} import java.io.*; io.* java public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        String[] temp = r.readLine().split(" ");
        int n = Integer.parseInt(temp[0]);
        temp = r.readLine().split(" ");
        long[] t = new long[n+1];
        for (int i = 0; i < n+1; i++) {
            t[i] = Long.parseLong(temp[i]);
        }
        temp = r.readLine().split(" ");
        long[] s = new long[n];
        for (int j = 0; j < n; j++) {
            s[j] = Long.parseLong(temp[j]);
        }
        r.close();

        long d = 0;
        long x;
        for (int k = 0; k < n; k++) {
            for (int l = 0; l < 2; l++) {
                x = Math.min(t[k + l], s[k]);
                t[k + l] = t[k + l] - x;
                s[k] = s[k] - x;
                d += x;
            }
        }
        System.out.println(d);
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        String[] temp = r.readLine().split(" ");
        int n = Integer.parseInt(temp[0]);
        temp = r.readLine().split(" ");
        long[] t = new long[n+1];
        for (int i = 0; i < n+1; i++) {
            t[i] = Long.parseLong(temp[i]);
        }
        temp = r.readLine().split(" ");
        long[] s = new long[n];
        for (int j = 0; j < n; j++) {
            s[j] = Long.parseLong(temp[j]);
        }
        r.close();

        long d = 0;
        long x;
        for (int k = 0; k < n; k++) {
            for (int l = 0; l < 2; l++) {
                x = Math.min(t[k + l], s[k]);
                t[k + l] = t[k + l] - x;
                s[k] = s[k] - x;
                d += x;
            }
        }
        System.out.println(d);
    } main {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        String[] temp = r.readLine().split(" ");
        int n = Integer.parseInt(temp[0]);
        temp = r.readLine().split(" ");
        long[] t = new long[n+1];
        for (int i = 0; i < n+1; i++) {
            t[i] = Long.parseLong(temp[i]);
        }
        temp = r.readLine().split(" ");
        long[] s = new long[n];
        for (int j = 0; j < n; j++) {
            s[j] = Long.parseLong(temp[j]);
        }
        r.close();

        long d = 0;
        long x;
        for (int k = 0; k < n; k++) {
            for (int l = 0; l < 2; l++) {
                x = Math.min(t[k + l], s[k]);
                t[k + l] = t[k + l] - x;
                s[k] = s[k] - x;
                d += x;
            }
        }
        System.out.println(d);
    } BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); r new BufferedReader(new InputStreamReader(System.in)) String[] temp = r.readLine().split(" "); temp r.readLine().split(" ") r.readLine().split r.readLine() r.readLine r " " int n = Integer.parseInt(temp[0]); n Integer.parseInt(temp[0]) Integer.parseInt Integer temp[0] temp 0 temp = r.readLine().split(" ") temp r.readLine().split(" ") r.readLine().split r.readLine() r.readLine r " " long[] t = new long[n+1]; t new long[n+1] n+1 n 1 for (int i = 0; i < n+1; i++) {
            t[i] = Long.parseLong(temp[i]);
        } int i = 0; int i = 0; i 0 i < n+1 i n+1 n 1 i++ i++ i {
            t[i] = Long.parseLong(temp[i]);
        } {
            t[i] = Long.parseLong(temp[i]);
        } t[i] = Long.parseLong(temp[i]) t[i] t i Long.parseLong(temp[i]) Long.parseLong Long temp[i] temp i temp = r.readLine().split(" ") temp r.readLine().split(" ") r.readLine().split r.readLine() r.readLine r " " long[] s = new long[n]; s new long[n] n for (int j = 0; j < n; j++) {
            s[j] = Long.parseLong(temp[j]);
        } int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
            s[j] = Long.parseLong(temp[j]);
        } {
            s[j] = Long.parseLong(temp[j]);
        } s[j] = Long.parseLong(temp[j]) s[j] s j Long.parseLong(temp[j]) Long.parseLong Long temp[j] temp j r.close() r.close r long d = 0; d 0 long x; x for (int k = 0; k < n; k++) {
            for (int l = 0; l < 2; l++) {
                x = Math.min(t[k + l], s[k]);
                t[k + l] = t[k + l] - x;
                s[k] = s[k] - x;
                d += x;
            }
        } int k = 0; int k = 0; k 0 k < n k n k++ k++ k {
            for (int l = 0; l < 2; l++) {
                x = Math.min(t[k + l], s[k]);
                t[k + l] = t[k + l] - x;
                s[k] = s[k] - x;
                d += x;
            }
        } {
            for (int l = 0; l < 2; l++) {
                x = Math.min(t[k + l], s[k]);
                t[k + l] = t[k + l] - x;
                s[k] = s[k] - x;
                d += x;
            }
        } for (int l = 0; l < 2; l++) {
                x = Math.min(t[k + l], s[k]);
                t[k + l] = t[k + l] - x;
                s[k] = s[k] - x;
                d += x;
            } int l = 0; int l = 0; l 0 l < 2 l 2 l++ l++ l {
                x = Math.min(t[k + l], s[k]);
                t[k + l] = t[k + l] - x;
                s[k] = s[k] - x;
                d += x;
            } {
                x = Math.min(t[k + l], s[k]);
                t[k + l] = t[k + l] - x;
                s[k] = s[k] - x;
                d += x;
            } x = Math.min(t[k + l], s[k]) x Math.min(t[k + l], s[k]) Math.min Math t[k + l] t k + l k l s[k] s k t[k + l] = t[k + l] - x t[k + l] t k + l k l t[k + l] - x t[k + l] t k + l k l x s[k] = s[k] - x s[k] s k s[k] - x s[k] s k x d += x d x System.out.println(d) System.out.println System.out System System.out d String[] args args public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        String[] temp = r.readLine().split(" ");
        int n = Integer.parseInt(temp[0]);
        temp = r.readLine().split(" ");
        long[] t = new long[n+1];
        for (int i = 0; i < n+1; i++) {
            t[i] = Long.parseLong(temp[i]);
        }
        temp = r.readLine().split(" ");
        long[] s = new long[n];
        for (int j = 0; j < n; j++) {
            s[j] = Long.parseLong(temp[j]);
        }
        r.close();

        long d = 0;
        long x;
        for (int k = 0; k < n; k++) {
            for (int l = 0; l < 2; l++) {
                x = Math.min(t[k + l], s[k]);
                t[k + l] = t[k + l] - x;
                s[k] = s[k] - x;
                d += x;
            }
        }
        System.out.println(d);
    }
} public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        String[] temp = r.readLine().split(" ");
        int n = Integer.parseInt(temp[0]);
        temp = r.readLine().split(" ");
        long[] t = new long[n+1];
        for (int i = 0; i < n+1; i++) {
            t[i] = Long.parseLong(temp[i]);
        }
        temp = r.readLine().split(" ");
        long[] s = new long[n];
        for (int j = 0; j < n; j++) {
            s[j] = Long.parseLong(temp[j]);
        }
        r.close();

        long d = 0;
        long x;
        for (int k = 0; k < n; k++) {
            for (int l = 0; l < 2; l++) {
                x = Math.min(t[k + l], s[k]);
                t[k + l] = t[k + l] - x;
                s[k] = s[k] - x;
                d += x;
            }
        }
        System.out.println(d);
    }
} Main
import java.io.*;

/**
 * Created by Ayushi on 27/07/2019.
 */

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        String[] temp = r.readLine().split(" ");
        int n = Integer.parseInt(temp[0]);
        temp = r.readLine().split(" ");
        long[] t = new long[n+1];
        for (int i = 0; i < n+1; i++) {
            t[i] = Long.parseLong(temp[i]);
        }
        temp = r.readLine().split(" ");
        long[] s = new long[n];
        for (int j = 0; j < n; j++) {
            s[j] = Long.parseLong(temp[j]);
        }
        r.close();

        long d = 0;
        long x;
        for (int k = 0; k < n; k++) {
            for (int l = 0; l < 2; l++) {
                x = Math.min(t[k + l], s[k]);
                t[k + l] = t[k + l] - x;
                s[k] = s[k] - x;
                d += x;
            }
        }
        System.out.println(d);
    }
}
