import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] monster = new Integer[n + 1];
        for (int i = 0; i < n + 1; i++) {
            monster[i] = sc.nextInt();
        }
        Integer[] bravePower = new Integer[n];
        for (int i = 0; i < n; i++) {
            bravePower[i] = sc.nextInt();
        }

        long result = 0;
        for (int i = 0; i < n; i++) {
            if (monster[i] >= bravePower[i]) {
                result += bravePower[i];
            } else {
                result += monster[i];
                bravePower[i] -= monster[i];
                result += Math.min(bravePower[i], monster[i + 1]);
                monster[i + 1] = Math.max(0, monster[i + 1] - bravePower[i]);
            }
        }

        System.out.println(result);
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] monster = new Integer[n + 1];
        for (int i = 0; i < n + 1; i++) {
            monster[i] = sc.nextInt();
        }
        Integer[] bravePower = new Integer[n];
        for (int i = 0; i < n; i++) {
            bravePower[i] = sc.nextInt();
        }

        long result = 0;
        for (int i = 0; i < n; i++) {
            if (monster[i] >= bravePower[i]) {
                result += bravePower[i];
            } else {
                result += monster[i];
                bravePower[i] -= monster[i];
                result += Math.min(bravePower[i], monster[i + 1]);
                monster[i + 1] = Math.max(0, monster[i + 1] - bravePower[i]);
            }
        }

        System.out.println(result);
    }
} Main public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] monster = new Integer[n + 1];
        for (int i = 0; i < n + 1; i++) {
            monster[i] = sc.nextInt();
        }
        Integer[] bravePower = new Integer[n];
        for (int i = 0; i < n; i++) {
            bravePower[i] = sc.nextInt();
        }

        long result = 0;
        for (int i = 0; i < n; i++) {
            if (monster[i] >= bravePower[i]) {
                result += bravePower[i];
            } else {
                result += monster[i];
                bravePower[i] -= monster[i];
                result += Math.min(bravePower[i], monster[i + 1]);
                monster[i + 1] = Math.max(0, monster[i + 1] - bravePower[i]);
            }
        }

        System.out.println(result);
    } main {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] monster = new Integer[n + 1];
        for (int i = 0; i < n + 1; i++) {
            monster[i] = sc.nextInt();
        }
        Integer[] bravePower = new Integer[n];
        for (int i = 0; i < n; i++) {
            bravePower[i] = sc.nextInt();
        }

        long result = 0;
        for (int i = 0; i < n; i++) {
            if (monster[i] >= bravePower[i]) {
                result += bravePower[i];
            } else {
                result += monster[i];
                bravePower[i] -= monster[i];
                result += Math.min(bravePower[i], monster[i + 1]);
                monster[i + 1] = Math.max(0, monster[i + 1] - bravePower[i]);
            }
        }

        System.out.println(result);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc Integer[] monster = new Integer[n + 1]; monster new Integer[n + 1] n + 1 n 1 for (int i = 0; i < n + 1; i++) {
            monster[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < n + 1 i n + 1 n 1 i++ i++ i {
            monster[i] = sc.nextInt();
        } {
            monster[i] = sc.nextInt();
        } monster[i] = sc.nextInt() monster[i] monster i sc.nextInt() sc.nextInt sc Integer[] bravePower = new Integer[n]; bravePower new Integer[n] n for (int i = 0; i < n; i++) {
            bravePower[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            bravePower[i] = sc.nextInt();
        } {
            bravePower[i] = sc.nextInt();
        } bravePower[i] = sc.nextInt() bravePower[i] bravePower i sc.nextInt() sc.nextInt sc long result = 0; result 0 for (int i = 0; i < n; i++) {
            if (monster[i] >= bravePower[i]) {
                result += bravePower[i];
            } else {
                result += monster[i];
                bravePower[i] -= monster[i];
                result += Math.min(bravePower[i], monster[i + 1]);
                monster[i + 1] = Math.max(0, monster[i + 1] - bravePower[i]);
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            if (monster[i] >= bravePower[i]) {
                result += bravePower[i];
            } else {
                result += monster[i];
                bravePower[i] -= monster[i];
                result += Math.min(bravePower[i], monster[i + 1]);
                monster[i + 1] = Math.max(0, monster[i + 1] - bravePower[i]);
            }
        } {
            if (monster[i] >= bravePower[i]) {
                result += bravePower[i];
            } else {
                result += monster[i];
                bravePower[i] -= monster[i];
                result += Math.min(bravePower[i], monster[i + 1]);
                monster[i + 1] = Math.max(0, monster[i + 1] - bravePower[i]);
            }
        } if (monster[i] >= bravePower[i]) {
                result += bravePower[i];
            } else {
                result += monster[i];
                bravePower[i] -= monster[i];
                result += Math.min(bravePower[i], monster[i + 1]);
                monster[i + 1] = Math.max(0, monster[i + 1] - bravePower[i]);
            } monster[i] >= bravePower[i] monster[i] monster i bravePower[i] bravePower i {
                result += bravePower[i];
            } result += bravePower[i] result bravePower[i] bravePower i {
                result += monster[i];
                bravePower[i] -= monster[i];
                result += Math.min(bravePower[i], monster[i + 1]);
                monster[i + 1] = Math.max(0, monster[i + 1] - bravePower[i]);
            } result += monster[i] result monster[i] monster i bravePower[i] -= monster[i] bravePower[i] bravePower i monster[i] monster i result += Math.min(bravePower[i], monster[i + 1]) result Math.min(bravePower[i], monster[i + 1]) Math.min Math bravePower[i] bravePower i monster[i + 1] monster i + 1 i 1 monster[i + 1] = Math.max(0, monster[i + 1] - bravePower[i]) monster[i + 1] monster i + 1 i 1 Math.max(0, monster[i + 1] - bravePower[i]) Math.max Math 0 monster[i + 1] - bravePower[i] monster[i + 1] monster i + 1 i 1 bravePower[i] bravePower i System.out.println(result) System.out.println System.out System System.out result String args[] args public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] monster = new Integer[n + 1];
        for (int i = 0; i < n + 1; i++) {
            monster[i] = sc.nextInt();
        }
        Integer[] bravePower = new Integer[n];
        for (int i = 0; i < n; i++) {
            bravePower[i] = sc.nextInt();
        }

        long result = 0;
        for (int i = 0; i < n; i++) {
            if (monster[i] >= bravePower[i]) {
                result += bravePower[i];
            } else {
                result += monster[i];
                bravePower[i] -= monster[i];
                result += Math.min(bravePower[i], monster[i + 1]);
                monster[i + 1] = Math.max(0, monster[i + 1] - bravePower[i]);
            }
        }

        System.out.println(result);
    }
} public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] monster = new Integer[n + 1];
        for (int i = 0; i < n + 1; i++) {
            monster[i] = sc.nextInt();
        }
        Integer[] bravePower = new Integer[n];
        for (int i = 0; i < n; i++) {
            bravePower[i] = sc.nextInt();
        }

        long result = 0;
        for (int i = 0; i < n; i++) {
            if (monster[i] >= bravePower[i]) {
                result += bravePower[i];
            } else {
                result += monster[i];
                bravePower[i] -= monster[i];
                result += Math.min(bravePower[i], monster[i + 1]);
                monster[i + 1] = Math.max(0, monster[i + 1] - bravePower[i]);
            }
        }

        System.out.println(result);
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] monster = new Integer[n + 1];
        for (int i = 0; i < n + 1; i++) {
            monster[i] = sc.nextInt();
        }
        Integer[] bravePower = new Integer[n];
        for (int i = 0; i < n; i++) {
            bravePower[i] = sc.nextInt();
        }

        long result = 0;
        for (int i = 0; i < n; i++) {
            if (monster[i] >= bravePower[i]) {
                result += bravePower[i];
            } else {
                result += monster[i];
                bravePower[i] -= monster[i];
                result += Math.min(bravePower[i], monster[i + 1]);
                monster[i + 1] = Math.max(0, monster[i + 1] - bravePower[i]);
            }
        }

        System.out.println(result);
    }
}
