import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int num = in.nextInt();
        int[] city = new int[num + 1];
        int[] brave = new int[num];
        for (int i = 0; i <= num; i++) {
            city[i] = Integer.parseInt(in.next());
        }
        for (int i = 0; i < num; i++) {
            brave[i] = Integer.parseInt(in.next());
        }
        long total = 0;
        int capa = 0;
        int capb = city[0];
        for (int i = 0; i < num; i++) {
            capa = capb;
            capb = city[i + 1];
            if (brave[i] <= capa) {
                total += brave[i];
                continue;
            } else {
                total += capa;
                int diff = brave[i] - capa;
                if (diff <= capb) {
                    capb -= diff;
                    total += diff;
                } else {
                    total += capb;
                    capb = 0;
                }
            }
        }
        System.out.println(total);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int num = in.nextInt();
        int[] city = new int[num + 1];
        int[] brave = new int[num];
        for (int i = 0; i <= num; i++) {
            city[i] = Integer.parseInt(in.next());
        }
        for (int i = 0; i < num; i++) {
            brave[i] = Integer.parseInt(in.next());
        }
        long total = 0;
        int capa = 0;
        int capb = city[0];
        for (int i = 0; i < num; i++) {
            capa = capb;
            capb = city[i + 1];
            if (brave[i] <= capa) {
                total += brave[i];
                continue;
            } else {
                total += capa;
                int diff = brave[i] - capa;
                if (diff <= capb) {
                    capb -= diff;
                    total += diff;
                } else {
                    total += capb;
                    capb = 0;
                }
            }
        }
        System.out.println(total);
    }
} Main public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int num = in.nextInt();
        int[] city = new int[num + 1];
        int[] brave = new int[num];
        for (int i = 0; i <= num; i++) {
            city[i] = Integer.parseInt(in.next());
        }
        for (int i = 0; i < num; i++) {
            brave[i] = Integer.parseInt(in.next());
        }
        long total = 0;
        int capa = 0;
        int capb = city[0];
        for (int i = 0; i < num; i++) {
            capa = capb;
            capb = city[i + 1];
            if (brave[i] <= capa) {
                total += brave[i];
                continue;
            } else {
                total += capa;
                int diff = brave[i] - capa;
                if (diff <= capb) {
                    capb -= diff;
                    total += diff;
                } else {
                    total += capb;
                    capb = 0;
                }
            }
        }
        System.out.println(total);
    } main {
        Scanner in = new Scanner(System.in);
        int num = in.nextInt();
        int[] city = new int[num + 1];
        int[] brave = new int[num];
        for (int i = 0; i <= num; i++) {
            city[i] = Integer.parseInt(in.next());
        }
        for (int i = 0; i < num; i++) {
            brave[i] = Integer.parseInt(in.next());
        }
        long total = 0;
        int capa = 0;
        int capb = city[0];
        for (int i = 0; i < num; i++) {
            capa = capb;
            capb = city[i + 1];
            if (brave[i] <= capa) {
                total += brave[i];
                continue;
            } else {
                total += capa;
                int diff = brave[i] - capa;
                if (diff <= capb) {
                    capb -= diff;
                    total += diff;
                } else {
                    total += capb;
                    capb = 0;
                }
            }
        }
        System.out.println(total);
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) int num = in.nextInt(); num in.nextInt() in.nextInt in int[] city = new int[num + 1]; city new int[num + 1] num + 1 num 1 int[] brave = new int[num]; brave new int[num] num for (int i = 0; i <= num; i++) {
            city[i] = Integer.parseInt(in.next());
        } int i = 0; int i = 0; i 0 i <= num i num i++ i++ i {
            city[i] = Integer.parseInt(in.next());
        } {
            city[i] = Integer.parseInt(in.next());
        } city[i] = Integer.parseInt(in.next()) city[i] city i Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in for (int i = 0; i < num; i++) {
            brave[i] = Integer.parseInt(in.next());
        } int i = 0; int i = 0; i 0 i < num i num i++ i++ i {
            brave[i] = Integer.parseInt(in.next());
        } {
            brave[i] = Integer.parseInt(in.next());
        } brave[i] = Integer.parseInt(in.next()) brave[i] brave i Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in long total = 0; total 0 int capa = 0; capa 0 int capb = city[0]; capb city[0] city 0 for (int i = 0; i < num; i++) {
            capa = capb;
            capb = city[i + 1];
            if (brave[i] <= capa) {
                total += brave[i];
                continue;
            } else {
                total += capa;
                int diff = brave[i] - capa;
                if (diff <= capb) {
                    capb -= diff;
                    total += diff;
                } else {
                    total += capb;
                    capb = 0;
                }
            }
        } int i = 0; int i = 0; i 0 i < num i num i++ i++ i {
            capa = capb;
            capb = city[i + 1];
            if (brave[i] <= capa) {
                total += brave[i];
                continue;
            } else {
                total += capa;
                int diff = brave[i] - capa;
                if (diff <= capb) {
                    capb -= diff;
                    total += diff;
                } else {
                    total += capb;
                    capb = 0;
                }
            }
        } {
            capa = capb;
            capb = city[i + 1];
            if (brave[i] <= capa) {
                total += brave[i];
                continue;
            } else {
                total += capa;
                int diff = brave[i] - capa;
                if (diff <= capb) {
                    capb -= diff;
                    total += diff;
                } else {
                    total += capb;
                    capb = 0;
                }
            }
        } capa = capb capa capb capb = city[i + 1] capb city[i + 1] city i + 1 i 1 if (brave[i] <= capa) {
                total += brave[i];
                continue;
            } else {
                total += capa;
                int diff = brave[i] - capa;
                if (diff <= capb) {
                    capb -= diff;
                    total += diff;
                } else {
                    total += capb;
                    capb = 0;
                }
            } brave[i] <= capa brave[i] brave i capa {
                total += brave[i];
                continue;
            } total += brave[i] total brave[i] brave i continue; {
                total += capa;
                int diff = brave[i] - capa;
                if (diff <= capb) {
                    capb -= diff;
                    total += diff;
                } else {
                    total += capb;
                    capb = 0;
                }
            } total += capa total capa int diff = brave[i] - capa; diff brave[i] - capa brave[i] brave i capa if (diff <= capb) {
                    capb -= diff;
                    total += diff;
                } else {
                    total += capb;
                    capb = 0;
                } diff <= capb diff capb {
                    capb -= diff;
                    total += diff;
                } capb -= diff capb diff total += diff total diff {
                    total += capb;
                    capb = 0;
                } total += capb total capb capb = 0 capb 0 System.out.println(total) System.out.println System.out System System.out total String[] args args public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int num = in.nextInt();
        int[] city = new int[num + 1];
        int[] brave = new int[num];
        for (int i = 0; i <= num; i++) {
            city[i] = Integer.parseInt(in.next());
        }
        for (int i = 0; i < num; i++) {
            brave[i] = Integer.parseInt(in.next());
        }
        long total = 0;
        int capa = 0;
        int capb = city[0];
        for (int i = 0; i < num; i++) {
            capa = capb;
            capb = city[i + 1];
            if (brave[i] <= capa) {
                total += brave[i];
                continue;
            } else {
                total += capa;
                int diff = brave[i] - capa;
                if (diff <= capb) {
                    capb -= diff;
                    total += diff;
                } else {
                    total += capb;
                    capb = 0;
                }
            }
        }
        System.out.println(total);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int num = in.nextInt();
        int[] city = new int[num + 1];
        int[] brave = new int[num];
        for (int i = 0; i <= num; i++) {
            city[i] = Integer.parseInt(in.next());
        }
        for (int i = 0; i < num; i++) {
            brave[i] = Integer.parseInt(in.next());
        }
        long total = 0;
        int capa = 0;
        int capb = city[0];
        for (int i = 0; i < num; i++) {
            capa = capb;
            capb = city[i + 1];
            if (brave[i] <= capa) {
                total += brave[i];
                continue;
            } else {
                total += capa;
                int diff = brave[i] - capa;
                if (diff <= capb) {
                    capb -= diff;
                    total += diff;
                } else {
                    total += capb;
                    capb = 0;
                }
            }
        }
        System.out.println(total);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int num = in.nextInt();
        int[] city = new int[num + 1];
        int[] brave = new int[num];
        for (int i = 0; i <= num; i++) {
            city[i] = Integer.parseInt(in.next());
        }
        for (int i = 0; i < num; i++) {
            brave[i] = Integer.parseInt(in.next());
        }
        long total = 0;
        int capa = 0;
        int capb = city[0];
        for (int i = 0; i < num; i++) {
            capa = capb;
            capb = city[i + 1];
            if (brave[i] <= capa) {
                total += brave[i];
                continue;
            } else {
                total += capa;
                int diff = brave[i] - capa;
                if (diff <= capb) {
                    capb -= diff;
                    total += diff;
                } else {
                    total += capb;
                    capb = 0;
                }
            }
        }
        System.out.println(total);
    }
}
