import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] A = new int[N + 1];
        for (int i = 0; i < A.length; ++i) {
            A[i] = sc.nextInt();
        }
        int[] B = new int[N];
        for (int i = 0; i < B.length; ++i) {
            B[i] = sc.nextInt();
        }

        System.out.println(solve(A, B));

        sc.close();
    }

    static long solve(int[] A, int[] B) {
        B = Arrays.copyOf(B, B.length + 1);

        long result = 0;
        int extraB = 0;
        for (int i = 0; i < A.length; ++i) {
            int defeatNum = Math.min(A[i], B[i] + extraB);

            result += defeatNum;
            extraB = Math.min(B[i], B[i] + extraB - defeatNum);
        }

        return result;
    }
} import java.util.Arrays; Arrays java.util 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[] A = new int[N + 1];
        for (int i = 0; i < A.length; ++i) {
            A[i] = sc.nextInt();
        }
        int[] B = new int[N];
        for (int i = 0; i < B.length; ++i) {
            B[i] = sc.nextInt();
        }

        System.out.println(solve(A, B));

        sc.close();
    }

    static long solve(int[] A, int[] B) {
        B = Arrays.copyOf(B, B.length + 1);

        long result = 0;
        int extraB = 0;
        for (int i = 0; i < A.length; ++i) {
            int defeatNum = Math.min(A[i], B[i] + extraB);

            result += defeatNum;
            extraB = Math.min(B[i], B[i] + extraB - defeatNum);
        }

        return result;
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] A = new int[N + 1];
        for (int i = 0; i < A.length; ++i) {
            A[i] = sc.nextInt();
        }
        int[] B = new int[N];
        for (int i = 0; i < B.length; ++i) {
            B[i] = sc.nextInt();
        }

        System.out.println(solve(A, B));

        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] A = new int[N + 1];
        for (int i = 0; i < A.length; ++i) {
            A[i] = sc.nextInt();
        }
        int[] B = new int[N];
        for (int i = 0; i < B.length; ++i) {
            B[i] = sc.nextInt();
        }

        System.out.println(solve(A, B));

        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] A = new int[N + 1]; A new int[N + 1] N + 1 N 1 for (int i = 0; i < A.length; ++i) {
            A[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < A.length i A.length A A.length ++i ++i i {
            A[i] = sc.nextInt();
        } {
            A[i] = sc.nextInt();
        } A[i] = sc.nextInt() A[i] A i sc.nextInt() sc.nextInt sc int[] B = new int[N]; B new int[N] N for (int i = 0; i < B.length; ++i) {
            B[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < B.length i B.length B B.length ++i ++i i {
            B[i] = sc.nextInt();
        } {
            B[i] = sc.nextInt();
        } B[i] = sc.nextInt() B[i] B i sc.nextInt() sc.nextInt sc System.out.println(solve(A, B)) System.out.println System.out System System.out solve(A, B) solve A B sc.close() sc.close sc String[] args args static long solve(int[] A, int[] B) {
        B = Arrays.copyOf(B, B.length + 1);

        long result = 0;
        int extraB = 0;
        for (int i = 0; i < A.length; ++i) {
            int defeatNum = Math.min(A[i], B[i] + extraB);

            result += defeatNum;
            extraB = Math.min(B[i], B[i] + extraB - defeatNum);
        }

        return result;
    } solve {
        B = Arrays.copyOf(B, B.length + 1);

        long result = 0;
        int extraB = 0;
        for (int i = 0; i < A.length; ++i) {
            int defeatNum = Math.min(A[i], B[i] + extraB);

            result += defeatNum;
            extraB = Math.min(B[i], B[i] + extraB - defeatNum);
        }

        return result;
    } B = Arrays.copyOf(B, B.length + 1) B Arrays.copyOf(B, B.length + 1) Arrays.copyOf Arrays B B.length + 1 B.length B B.length 1 long result = 0; result 0 int extraB = 0; extraB 0 for (int i = 0; i < A.length; ++i) {
            int defeatNum = Math.min(A[i], B[i] + extraB);

            result += defeatNum;
            extraB = Math.min(B[i], B[i] + extraB - defeatNum);
        } int i = 0; int i = 0; i 0 i < A.length i A.length A A.length ++i ++i i {
            int defeatNum = Math.min(A[i], B[i] + extraB);

            result += defeatNum;
            extraB = Math.min(B[i], B[i] + extraB - defeatNum);
        } {
            int defeatNum = Math.min(A[i], B[i] + extraB);

            result += defeatNum;
            extraB = Math.min(B[i], B[i] + extraB - defeatNum);
        } int defeatNum = Math.min(A[i], B[i] + extraB); defeatNum Math.min(A[i], B[i] + extraB) Math.min Math A[i] A i B[i] + extraB B[i] B i extraB result += defeatNum result defeatNum extraB = Math.min(B[i], B[i] + extraB - defeatNum) extraB Math.min(B[i], B[i] + extraB - defeatNum) Math.min Math B[i] B i B[i] + extraB - defeatNum B[i] + extraB B[i] B i extraB defeatNum return result; result int[] A A int[] B B public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] A = new int[N + 1];
        for (int i = 0; i < A.length; ++i) {
            A[i] = sc.nextInt();
        }
        int[] B = new int[N];
        for (int i = 0; i < B.length; ++i) {
            B[i] = sc.nextInt();
        }

        System.out.println(solve(A, B));

        sc.close();
    }

    static long solve(int[] A, int[] B) {
        B = Arrays.copyOf(B, B.length + 1);

        long result = 0;
        int extraB = 0;
        for (int i = 0; i < A.length; ++i) {
            int defeatNum = Math.min(A[i], B[i] + extraB);

            result += defeatNum;
            extraB = Math.min(B[i], B[i] + extraB - defeatNum);
        }

        return result;
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] A = new int[N + 1];
        for (int i = 0; i < A.length; ++i) {
            A[i] = sc.nextInt();
        }
        int[] B = new int[N];
        for (int i = 0; i < B.length; ++i) {
            B[i] = sc.nextInt();
        }

        System.out.println(solve(A, B));

        sc.close();
    }

    static long solve(int[] A, int[] B) {
        B = Arrays.copyOf(B, B.length + 1);

        long result = 0;
        int extraB = 0;
        for (int i = 0; i < A.length; ++i) {
            int defeatNum = Math.min(A[i], B[i] + extraB);

            result += defeatNum;
            extraB = Math.min(B[i], B[i] + extraB - defeatNum);
        }

        return result;
    }
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] A = new int[N + 1];
        for (int i = 0; i < A.length; ++i) {
            A[i] = sc.nextInt();
        }
        int[] B = new int[N];
        for (int i = 0; i < B.length; ++i) {
            B[i] = sc.nextInt();
        }

        System.out.println(solve(A, B));

        sc.close();
    }

    static long solve(int[] A, int[] B) {
        B = Arrays.copyOf(B, B.length + 1);

        long result = 0;
        int extraB = 0;
        for (int i = 0; i < A.length; ++i) {
            int defeatNum = Math.min(A[i], B[i] + extraB);

            result += defeatNum;
            extraB = Math.min(B[i], B[i] + extraB - defeatNum);
        }

        return result;
    }
}