import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        long[] a = new long[N + 1];
        for (int i = 0; i < N + 1; i++) {
            a[i] = scanner.nextLong();
        }
        long[] b = new long[N];
        for (int i = 0; i < N; i++) {
            b[i] = scanner.nextLong();
        }

        long result = 0;
        long defeated;
        for (int i=0; i < N; i++) {
            defeated = Math.min(a[i], b[i]);
            result += defeated;
            defeated = Math.min(a[i+1], b[i]-defeated);
            a[i+1] -= defeated;
            result += defeated;
        }
        System.out.println(result);
    }
} 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();
        long[] a = new long[N + 1];
        for (int i = 0; i < N + 1; i++) {
            a[i] = scanner.nextLong();
        }
        long[] b = new long[N];
        for (int i = 0; i < N; i++) {
            b[i] = scanner.nextLong();
        }

        long result = 0;
        long defeated;
        for (int i=0; i < N; i++) {
            defeated = Math.min(a[i], b[i]);
            result += defeated;
            defeated = Math.min(a[i+1], b[i]-defeated);
            a[i+1] -= defeated;
            result += defeated;
        }
        System.out.println(result);
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        long[] a = new long[N + 1];
        for (int i = 0; i < N + 1; i++) {
            a[i] = scanner.nextLong();
        }
        long[] b = new long[N];
        for (int i = 0; i < N; i++) {
            b[i] = scanner.nextLong();
        }

        long result = 0;
        long defeated;
        for (int i=0; i < N; i++) {
            defeated = Math.min(a[i], b[i]);
            result += defeated;
            defeated = Math.min(a[i+1], b[i]-defeated);
            a[i+1] -= defeated;
            result += defeated;
        }
        System.out.println(result);
    } main {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        long[] a = new long[N + 1];
        for (int i = 0; i < N + 1; i++) {
            a[i] = scanner.nextLong();
        }
        long[] b = new long[N];
        for (int i = 0; i < N; i++) {
            b[i] = scanner.nextLong();
        }

        long result = 0;
        long defeated;
        for (int i=0; i < N; i++) {
            defeated = Math.min(a[i], b[i]);
            result += defeated;
            defeated = Math.min(a[i+1], b[i]-defeated);
            a[i+1] -= defeated;
            result += defeated;
        }
        System.out.println(result);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner long[] a = new long[N + 1]; a new long[N + 1] N + 1 N 1 for (int i = 0; i < N + 1; i++) {
            a[i] = scanner.nextLong();
        } int i = 0; int i = 0; i 0 i < N + 1 i N + 1 N 1 i++ i++ i {
            a[i] = scanner.nextLong();
        } {
            a[i] = scanner.nextLong();
        } a[i] = scanner.nextLong() a[i] a i scanner.nextLong() scanner.nextLong scanner long[] b = new long[N]; b new long[N] N for (int i = 0; i < N; i++) {
            b[i] = scanner.nextLong();
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            b[i] = scanner.nextLong();
        } {
            b[i] = scanner.nextLong();
        } b[i] = scanner.nextLong() b[i] b i scanner.nextLong() scanner.nextLong scanner long result = 0; result 0 long defeated; defeated for (int i=0; i < N; i++) {
            defeated = Math.min(a[i], b[i]);
            result += defeated;
            defeated = Math.min(a[i+1], b[i]-defeated);
            a[i+1] -= defeated;
            result += defeated;
        } int i=0; int i=0; i 0 i < N i N i++ i++ i {
            defeated = Math.min(a[i], b[i]);
            result += defeated;
            defeated = Math.min(a[i+1], b[i]-defeated);
            a[i+1] -= defeated;
            result += defeated;
        } {
            defeated = Math.min(a[i], b[i]);
            result += defeated;
            defeated = Math.min(a[i+1], b[i]-defeated);
            a[i+1] -= defeated;
            result += defeated;
        } defeated = Math.min(a[i], b[i]) defeated Math.min(a[i], b[i]) Math.min Math a[i] a i b[i] b i result += defeated result defeated defeated = Math.min(a[i+1], b[i]-defeated) defeated Math.min(a[i+1], b[i]-defeated) Math.min Math a[i+1] a i+1 i 1 b[i]-defeated b[i] b i defeated a[i+1] -= defeated a[i+1] a i+1 i 1 defeated result += defeated result defeated 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 scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        long[] a = new long[N + 1];
        for (int i = 0; i < N + 1; i++) {
            a[i] = scanner.nextLong();
        }
        long[] b = new long[N];
        for (int i = 0; i < N; i++) {
            b[i] = scanner.nextLong();
        }

        long result = 0;
        long defeated;
        for (int i=0; i < N; i++) {
            defeated = Math.min(a[i], b[i]);
            result += defeated;
            defeated = Math.min(a[i+1], b[i]-defeated);
            a[i+1] -= defeated;
            result += defeated;
        }
        System.out.println(result);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        long[] a = new long[N + 1];
        for (int i = 0; i < N + 1; i++) {
            a[i] = scanner.nextLong();
        }
        long[] b = new long[N];
        for (int i = 0; i < N; i++) {
            b[i] = scanner.nextLong();
        }

        long result = 0;
        long defeated;
        for (int i=0; i < N; i++) {
            defeated = Math.min(a[i], b[i]);
            result += defeated;
            defeated = Math.min(a[i+1], b[i]-defeated);
            a[i+1] -= defeated;
            result += defeated;
        }
        System.out.println(result);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        long[] a = new long[N + 1];
        for (int i = 0; i < N + 1; i++) {
            a[i] = scanner.nextLong();
        }
        long[] b = new long[N];
        for (int i = 0; i < N; i++) {
            b[i] = scanner.nextLong();
        }

        long result = 0;
        long defeated;
        for (int i=0; i < N; i++) {
            defeated = Math.min(a[i], b[i]);
            result += defeated;
            defeated = Math.min(a[i+1], b[i]-defeated);
            a[i+1] -= defeated;
            result += defeated;
        }
        System.out.println(result);
    }
}