import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] monsters = new int[n + 1];
        int[] heroes = new int[n];

        for (int i = 0; i < n + 1; i++)
            monsters[i] = sc.nextInt();
        for (int i = 0; i < n; i++)
            heroes[i] = sc.nextInt();

        int rem = 0;
        long totalKilled = 0;
        for (int i = 0; i < n; i++) {
            int killedPrev = Math.min(rem, monsters[i]);
            int killedNow = Math.min(monsters[i] - killedPrev, heroes[i]);

            totalKilled += killedPrev + killedNow;
            rem = Math.max(heroes[i] - killedNow, 0);
        }
        totalKilled += Math.min(rem, monsters[n]);
        System.out.println(totalKilled);
    }
} 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();
        int[] monsters = new int[n + 1];
        int[] heroes = new int[n];

        for (int i = 0; i < n + 1; i++)
            monsters[i] = sc.nextInt();
        for (int i = 0; i < n; i++)
            heroes[i] = sc.nextInt();

        int rem = 0;
        long totalKilled = 0;
        for (int i = 0; i < n; i++) {
            int killedPrev = Math.min(rem, monsters[i]);
            int killedNow = Math.min(monsters[i] - killedPrev, heroes[i]);

            totalKilled += killedPrev + killedNow;
            rem = Math.max(heroes[i] - killedNow, 0);
        }
        totalKilled += Math.min(rem, monsters[n]);
        System.out.println(totalKilled);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] monsters = new int[n + 1];
        int[] heroes = new int[n];

        for (int i = 0; i < n + 1; i++)
            monsters[i] = sc.nextInt();
        for (int i = 0; i < n; i++)
            heroes[i] = sc.nextInt();

        int rem = 0;
        long totalKilled = 0;
        for (int i = 0; i < n; i++) {
            int killedPrev = Math.min(rem, monsters[i]);
            int killedNow = Math.min(monsters[i] - killedPrev, heroes[i]);

            totalKilled += killedPrev + killedNow;
            rem = Math.max(heroes[i] - killedNow, 0);
        }
        totalKilled += Math.min(rem, monsters[n]);
        System.out.println(totalKilled);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] monsters = new int[n + 1];
        int[] heroes = new int[n];

        for (int i = 0; i < n + 1; i++)
            monsters[i] = sc.nextInt();
        for (int i = 0; i < n; i++)
            heroes[i] = sc.nextInt();

        int rem = 0;
        long totalKilled = 0;
        for (int i = 0; i < n; i++) {
            int killedPrev = Math.min(rem, monsters[i]);
            int killedNow = Math.min(monsters[i] - killedPrev, heroes[i]);

            totalKilled += killedPrev + killedNow;
            rem = Math.max(heroes[i] - killedNow, 0);
        }
        totalKilled += Math.min(rem, monsters[n]);
        System.out.println(totalKilled);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] monsters = new int[n + 1]; monsters new int[n + 1] n + 1 n 1 int[] heroes = new int[n]; heroes new int[n] n for (int i = 0; i < n + 1; i++)
            monsters[i] = sc.nextInt(); int i = 0; int i = 0; i 0 i < n + 1 i n + 1 n 1 i++ i++ i monsters[i] = sc.nextInt(); monsters[i] = sc.nextInt() monsters[i] monsters i sc.nextInt() sc.nextInt sc for (int i = 0; i < n; i++)
            heroes[i] = sc.nextInt(); int i = 0; int i = 0; i 0 i < n i n i++ i++ i heroes[i] = sc.nextInt(); heroes[i] = sc.nextInt() heroes[i] heroes i sc.nextInt() sc.nextInt sc int rem = 0; rem 0 long totalKilled = 0; totalKilled 0 for (int i = 0; i < n; i++) {
            int killedPrev = Math.min(rem, monsters[i]);
            int killedNow = Math.min(monsters[i] - killedPrev, heroes[i]);

            totalKilled += killedPrev + killedNow;
            rem = Math.max(heroes[i] - killedNow, 0);
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            int killedPrev = Math.min(rem, monsters[i]);
            int killedNow = Math.min(monsters[i] - killedPrev, heroes[i]);

            totalKilled += killedPrev + killedNow;
            rem = Math.max(heroes[i] - killedNow, 0);
        } {
            int killedPrev = Math.min(rem, monsters[i]);
            int killedNow = Math.min(monsters[i] - killedPrev, heroes[i]);

            totalKilled += killedPrev + killedNow;
            rem = Math.max(heroes[i] - killedNow, 0);
        } int killedPrev = Math.min(rem, monsters[i]); killedPrev Math.min(rem, monsters[i]) Math.min Math rem monsters[i] monsters i int killedNow = Math.min(monsters[i] - killedPrev, heroes[i]); killedNow Math.min(monsters[i] - killedPrev, heroes[i]) Math.min Math monsters[i] - killedPrev monsters[i] monsters i killedPrev heroes[i] heroes i totalKilled += killedPrev + killedNow totalKilled killedPrev + killedNow killedPrev killedNow rem = Math.max(heroes[i] - killedNow, 0) rem Math.max(heroes[i] - killedNow, 0) Math.max Math heroes[i] - killedNow heroes[i] heroes i killedNow 0 totalKilled += Math.min(rem, monsters[n]) totalKilled Math.min(rem, monsters[n]) Math.min Math rem monsters[n] monsters n System.out.println(totalKilled) System.out.println System.out System System.out totalKilled String[] args args public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] monsters = new int[n + 1];
        int[] heroes = new int[n];

        for (int i = 0; i < n + 1; i++)
            monsters[i] = sc.nextInt();
        for (int i = 0; i < n; i++)
            heroes[i] = sc.nextInt();

        int rem = 0;
        long totalKilled = 0;
        for (int i = 0; i < n; i++) {
            int killedPrev = Math.min(rem, monsters[i]);
            int killedNow = Math.min(monsters[i] - killedPrev, heroes[i]);

            totalKilled += killedPrev + killedNow;
            rem = Math.max(heroes[i] - killedNow, 0);
        }
        totalKilled += Math.min(rem, monsters[n]);
        System.out.println(totalKilled);
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] monsters = new int[n + 1];
        int[] heroes = new int[n];

        for (int i = 0; i < n + 1; i++)
            monsters[i] = sc.nextInt();
        for (int i = 0; i < n; i++)
            heroes[i] = sc.nextInt();

        int rem = 0;
        long totalKilled = 0;
        for (int i = 0; i < n; i++) {
            int killedPrev = Math.min(rem, monsters[i]);
            int killedNow = Math.min(monsters[i] - killedPrev, heroes[i]);

            totalKilled += killedPrev + killedNow;
            rem = Math.max(heroes[i] - killedNow, 0);
        }
        totalKilled += Math.min(rem, monsters[n]);
        System.out.println(totalKilled);
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] monsters = new int[n + 1];
        int[] heroes = new int[n];

        for (int i = 0; i < n + 1; i++)
            monsters[i] = sc.nextInt();
        for (int i = 0; i < n; i++)
            heroes[i] = sc.nextInt();

        int rem = 0;
        long totalKilled = 0;
        for (int i = 0; i < n; i++) {
            int killedPrev = Math.min(rem, monsters[i]);
            int killedNow = Math.min(monsters[i] - killedPrev, heroes[i]);

            totalKilled += killedPrev + killedNow;
            rem = Math.max(heroes[i] - killedNow, 0);
        }
        totalKilled += Math.min(rem, monsters[n]);
        System.out.println(totalKilled);
    }
}
