
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n + 1];
        int[] b = new int[n];

        for (int i = 0; i < n + 1; i++) {
            a[i] = scanner.nextInt();
        }

        for (int i = 0; i < n; i++) {
            b[i] = scanner.nextInt();
        }

        long totalDefeated = 0;

        for (int i = 0; i < n; i++) {
            if (b[i] > a[i]) {
                totalDefeated += a[i];
                b[i] -= a[i];
                totalDefeated += Math.min(b[i], a[i + 1]);
                a[i + 1] = Math.max(0, a[i + 1] - b[i]);
            } else {
                totalDefeated += b[i];
            }
        }

        System.out.println(totalDefeated);

    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n + 1];
        int[] b = new int[n];

        for (int i = 0; i < n + 1; i++) {
            a[i] = scanner.nextInt();
        }

        for (int i = 0; i < n; i++) {
            b[i] = scanner.nextInt();
        }

        long totalDefeated = 0;

        for (int i = 0; i < n; i++) {
            if (b[i] > a[i]) {
                totalDefeated += a[i];
                b[i] -= a[i];
                totalDefeated += Math.min(b[i], a[i + 1]);
                a[i + 1] = Math.max(0, a[i + 1] - b[i]);
            } else {
                totalDefeated += b[i];
            }
        }

        System.out.println(totalDefeated);

    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n + 1];
        int[] b = new int[n];

        for (int i = 0; i < n + 1; i++) {
            a[i] = scanner.nextInt();
        }

        for (int i = 0; i < n; i++) {
            b[i] = scanner.nextInt();
        }

        long totalDefeated = 0;

        for (int i = 0; i < n; i++) {
            if (b[i] > a[i]) {
                totalDefeated += a[i];
                b[i] -= a[i];
                totalDefeated += Math.min(b[i], a[i + 1]);
                a[i + 1] = Math.max(0, a[i + 1] - b[i]);
            } else {
                totalDefeated += b[i];
            }
        }

        System.out.println(totalDefeated);

    } main {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n + 1];
        int[] b = new int[n];

        for (int i = 0; i < n + 1; i++) {
            a[i] = scanner.nextInt();
        }

        for (int i = 0; i < n; i++) {
            b[i] = scanner.nextInt();
        }

        long totalDefeated = 0;

        for (int i = 0; i < n; i++) {
            if (b[i] > a[i]) {
                totalDefeated += a[i];
                b[i] -= a[i];
                totalDefeated += Math.min(b[i], a[i + 1]);
                a[i + 1] = Math.max(0, a[i + 1] - b[i]);
            } else {
                totalDefeated += b[i];
            }
        }

        System.out.println(totalDefeated);

    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int[] a = new int[n + 1]; a new int[n + 1] n + 1 n 1 int[] b = new int[n]; b new int[n] n for (int i = 0; i < n + 1; i++) {
            a[i] = scanner.nextInt();
        } int i = 0; int i = 0; i 0 i < n + 1 i n + 1 n 1 i++ i++ i {
            a[i] = scanner.nextInt();
        } {
            a[i] = scanner.nextInt();
        } a[i] = scanner.nextInt() a[i] a i scanner.nextInt() scanner.nextInt scanner for (int i = 0; i < n; i++) {
            b[i] = scanner.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            b[i] = scanner.nextInt();
        } {
            b[i] = scanner.nextInt();
        } b[i] = scanner.nextInt() b[i] b i scanner.nextInt() scanner.nextInt scanner long totalDefeated = 0; totalDefeated 0 for (int i = 0; i < n; i++) {
            if (b[i] > a[i]) {
                totalDefeated += a[i];
                b[i] -= a[i];
                totalDefeated += Math.min(b[i], a[i + 1]);
                a[i + 1] = Math.max(0, a[i + 1] - b[i]);
            } else {
                totalDefeated += b[i];
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            if (b[i] > a[i]) {
                totalDefeated += a[i];
                b[i] -= a[i];
                totalDefeated += Math.min(b[i], a[i + 1]);
                a[i + 1] = Math.max(0, a[i + 1] - b[i]);
            } else {
                totalDefeated += b[i];
            }
        } {
            if (b[i] > a[i]) {
                totalDefeated += a[i];
                b[i] -= a[i];
                totalDefeated += Math.min(b[i], a[i + 1]);
                a[i + 1] = Math.max(0, a[i + 1] - b[i]);
            } else {
                totalDefeated += b[i];
            }
        } if (b[i] > a[i]) {
                totalDefeated += a[i];
                b[i] -= a[i];
                totalDefeated += Math.min(b[i], a[i + 1]);
                a[i + 1] = Math.max(0, a[i + 1] - b[i]);
            } else {
                totalDefeated += b[i];
            } b[i] > a[i] b[i] b i a[i] a i {
                totalDefeated += a[i];
                b[i] -= a[i];
                totalDefeated += Math.min(b[i], a[i + 1]);
                a[i + 1] = Math.max(0, a[i + 1] - b[i]);
            } totalDefeated += a[i] totalDefeated a[i] a i b[i] -= a[i] b[i] b i a[i] a i totalDefeated += Math.min(b[i], a[i + 1]) totalDefeated Math.min(b[i], a[i + 1]) Math.min Math b[i] b i a[i + 1] a i + 1 i 1 a[i + 1] = Math.max(0, a[i + 1] - b[i]) a[i + 1] a i + 1 i 1 Math.max(0, a[i + 1] - b[i]) Math.max Math 0 a[i + 1] - b[i] a[i + 1] a i + 1 i 1 b[i] b i {
                totalDefeated += b[i];
            } totalDefeated += b[i] totalDefeated b[i] b i System.out.println(totalDefeated) System.out.println System.out System System.out totalDefeated String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n + 1];
        int[] b = new int[n];

        for (int i = 0; i < n + 1; i++) {
            a[i] = scanner.nextInt();
        }

        for (int i = 0; i < n; i++) {
            b[i] = scanner.nextInt();
        }

        long totalDefeated = 0;

        for (int i = 0; i < n; i++) {
            if (b[i] > a[i]) {
                totalDefeated += a[i];
                b[i] -= a[i];
                totalDefeated += Math.min(b[i], a[i + 1]);
                a[i + 1] = Math.max(0, a[i + 1] - b[i]);
            } else {
                totalDefeated += b[i];
            }
        }

        System.out.println(totalDefeated);

    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n + 1];
        int[] b = new int[n];

        for (int i = 0; i < n + 1; i++) {
            a[i] = scanner.nextInt();
        }

        for (int i = 0; i < n; i++) {
            b[i] = scanner.nextInt();
        }

        long totalDefeated = 0;

        for (int i = 0; i < n; i++) {
            if (b[i] > a[i]) {
                totalDefeated += a[i];
                b[i] -= a[i];
                totalDefeated += Math.min(b[i], a[i + 1]);
                a[i + 1] = Math.max(0, a[i + 1] - b[i]);
            } else {
                totalDefeated += b[i];
            }
        }

        System.out.println(totalDefeated);

    }
} Main

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n + 1];
        int[] b = new int[n];

        for (int i = 0; i < n + 1; i++) {
            a[i] = scanner.nextInt();
        }

        for (int i = 0; i < n; i++) {
            b[i] = scanner.nextInt();
        }

        long totalDefeated = 0;

        for (int i = 0; i < n; i++) {
            if (b[i] > a[i]) {
                totalDefeated += a[i];
                b[i] -= a[i];
                totalDefeated += Math.min(b[i], a[i + 1]);
                a[i + 1] = Math.max(0, a[i + 1] - b[i]);
            } else {
                totalDefeated += b[i];
            }
        }

        System.out.println(totalDefeated);

    }
}