import java.util.Scanner;

public class Main {
    public static int N = 0;
    public static int[] A;
    public static int[] B;

    public static void main(String[] args) {

        String[] aStrArray;
        String[] bStrArray;

        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        sc.nextLine();

        aStrArray = sc.nextLine().split(" ");
        A = new int[N + 1];
        for (int i = 0; i < N + 1; i++) {
            A[i] = Integer.parseInt(aStrArray[i]);
        }
        bStrArray = sc.nextLine().split(" ");
        B = new int[N];
        for (int i = 0; i < N; i++) {
            B[i] = Integer.parseInt(bStrArray[i]);
        }

        long tmp = 0;
        long remainingA = A[N];
        long totalEnemy;
        for (int i = N - 1; i >= 0; i--) {
            totalEnemy = A[i] + remainingA;
            if (B[i] >= totalEnemy) {
                tmp += totalEnemy;
                remainingA = 0;
            } else {
                tmp += B[i];
                if (remainingA - B[i] > 0) {
                    remainingA = A[i];
                } else {
                    remainingA = A[i] - (B[i] - remainingA);
                }
            }
        }
        System.out.println(tmp);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static int N = 0;
    public static int[] A;
    public static int[] B;

    public static void main(String[] args) {

        String[] aStrArray;
        String[] bStrArray;

        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        sc.nextLine();

        aStrArray = sc.nextLine().split(" ");
        A = new int[N + 1];
        for (int i = 0; i < N + 1; i++) {
            A[i] = Integer.parseInt(aStrArray[i]);
        }
        bStrArray = sc.nextLine().split(" ");
        B = new int[N];
        for (int i = 0; i < N; i++) {
            B[i] = Integer.parseInt(bStrArray[i]);
        }

        long tmp = 0;
        long remainingA = A[N];
        long totalEnemy;
        for (int i = N - 1; i >= 0; i--) {
            totalEnemy = A[i] + remainingA;
            if (B[i] >= totalEnemy) {
                tmp += totalEnemy;
                remainingA = 0;
            } else {
                tmp += B[i];
                if (remainingA - B[i] > 0) {
                    remainingA = A[i];
                } else {
                    remainingA = A[i] - (B[i] - remainingA);
                }
            }
        }
        System.out.println(tmp);
    }
} Main public static int N = 0; N 0 public static int[] A; A public static int[] B; B public static void main(String[] args) {

        String[] aStrArray;
        String[] bStrArray;

        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        sc.nextLine();

        aStrArray = sc.nextLine().split(" ");
        A = new int[N + 1];
        for (int i = 0; i < N + 1; i++) {
            A[i] = Integer.parseInt(aStrArray[i]);
        }
        bStrArray = sc.nextLine().split(" ");
        B = new int[N];
        for (int i = 0; i < N; i++) {
            B[i] = Integer.parseInt(bStrArray[i]);
        }

        long tmp = 0;
        long remainingA = A[N];
        long totalEnemy;
        for (int i = N - 1; i >= 0; i--) {
            totalEnemy = A[i] + remainingA;
            if (B[i] >= totalEnemy) {
                tmp += totalEnemy;
                remainingA = 0;
            } else {
                tmp += B[i];
                if (remainingA - B[i] > 0) {
                    remainingA = A[i];
                } else {
                    remainingA = A[i] - (B[i] - remainingA);
                }
            }
        }
        System.out.println(tmp);
    } main {

        String[] aStrArray;
        String[] bStrArray;

        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        sc.nextLine();

        aStrArray = sc.nextLine().split(" ");
        A = new int[N + 1];
        for (int i = 0; i < N + 1; i++) {
            A[i] = Integer.parseInt(aStrArray[i]);
        }
        bStrArray = sc.nextLine().split(" ");
        B = new int[N];
        for (int i = 0; i < N; i++) {
            B[i] = Integer.parseInt(bStrArray[i]);
        }

        long tmp = 0;
        long remainingA = A[N];
        long totalEnemy;
        for (int i = N - 1; i >= 0; i--) {
            totalEnemy = A[i] + remainingA;
            if (B[i] >= totalEnemy) {
                tmp += totalEnemy;
                remainingA = 0;
            } else {
                tmp += B[i];
                if (remainingA - B[i] > 0) {
                    remainingA = A[i];
                } else {
                    remainingA = A[i] - (B[i] - remainingA);
                }
            }
        }
        System.out.println(tmp);
    } String[] aStrArray; aStrArray String[] bStrArray; bStrArray Scanner sc = new Scanner(System.in); sc new Scanner(System.in) N = sc.nextInt() N sc.nextInt() sc.nextInt sc sc.nextLine() sc.nextLine sc aStrArray = sc.nextLine().split(" ") aStrArray sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " A = new int[N + 1] A new int[N + 1] N + 1 N 1 for (int i = 0; i < N + 1; i++) {
            A[i] = Integer.parseInt(aStrArray[i]);
        } int i = 0; int i = 0; i 0 i < N + 1 i N + 1 N 1 i++ i++ i {
            A[i] = Integer.parseInt(aStrArray[i]);
        } {
            A[i] = Integer.parseInt(aStrArray[i]);
        } A[i] = Integer.parseInt(aStrArray[i]) A[i] A i Integer.parseInt(aStrArray[i]) Integer.parseInt Integer aStrArray[i] aStrArray i bStrArray = sc.nextLine().split(" ") bStrArray sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " B = new int[N] B new int[N] N for (int i = 0; i < N; i++) {
            B[i] = Integer.parseInt(bStrArray[i]);
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            B[i] = Integer.parseInt(bStrArray[i]);
        } {
            B[i] = Integer.parseInt(bStrArray[i]);
        } B[i] = Integer.parseInt(bStrArray[i]) B[i] B i Integer.parseInt(bStrArray[i]) Integer.parseInt Integer bStrArray[i] bStrArray i long tmp = 0; tmp 0 long remainingA = A[N]; remainingA A[N] A N long totalEnemy; totalEnemy for (int i = N - 1; i >= 0; i--) {
            totalEnemy = A[i] + remainingA;
            if (B[i] >= totalEnemy) {
                tmp += totalEnemy;
                remainingA = 0;
            } else {
                tmp += B[i];
                if (remainingA - B[i] > 0) {
                    remainingA = A[i];
                } else {
                    remainingA = A[i] - (B[i] - remainingA);
                }
            }
        } int i = N - 1; int i = N - 1; i N - 1 N 1 i >= 0 i 0 i-- i-- i {
            totalEnemy = A[i] + remainingA;
            if (B[i] >= totalEnemy) {
                tmp += totalEnemy;
                remainingA = 0;
            } else {
                tmp += B[i];
                if (remainingA - B[i] > 0) {
                    remainingA = A[i];
                } else {
                    remainingA = A[i] - (B[i] - remainingA);
                }
            }
        } {
            totalEnemy = A[i] + remainingA;
            if (B[i] >= totalEnemy) {
                tmp += totalEnemy;
                remainingA = 0;
            } else {
                tmp += B[i];
                if (remainingA - B[i] > 0) {
                    remainingA = A[i];
                } else {
                    remainingA = A[i] - (B[i] - remainingA);
                }
            }
        } totalEnemy = A[i] + remainingA totalEnemy A[i] + remainingA A[i] A i remainingA if (B[i] >= totalEnemy) {
                tmp += totalEnemy;
                remainingA = 0;
            } else {
                tmp += B[i];
                if (remainingA - B[i] > 0) {
                    remainingA = A[i];
                } else {
                    remainingA = A[i] - (B[i] - remainingA);
                }
            } B[i] >= totalEnemy B[i] B i totalEnemy {
                tmp += totalEnemy;
                remainingA = 0;
            } tmp += totalEnemy tmp totalEnemy remainingA = 0 remainingA 0 {
                tmp += B[i];
                if (remainingA - B[i] > 0) {
                    remainingA = A[i];
                } else {
                    remainingA = A[i] - (B[i] - remainingA);
                }
            } tmp += B[i] tmp B[i] B i if (remainingA - B[i] > 0) {
                    remainingA = A[i];
                } else {
                    remainingA = A[i] - (B[i] - remainingA);
                } remainingA - B[i] > 0 remainingA - B[i] remainingA B[i] B i 0 {
                    remainingA = A[i];
                } remainingA = A[i] remainingA A[i] A i {
                    remainingA = A[i] - (B[i] - remainingA);
                } remainingA = A[i] - (B[i] - remainingA) remainingA A[i] - (B[i] - remainingA) A[i] A i (B[i] - remainingA) B[i] B i remainingA System.out.println(tmp) System.out.println System.out System System.out tmp String[] args args public class Main {
    public static int N = 0;
    public static int[] A;
    public static int[] B;

    public static void main(String[] args) {

        String[] aStrArray;
        String[] bStrArray;

        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        sc.nextLine();

        aStrArray = sc.nextLine().split(" ");
        A = new int[N + 1];
        for (int i = 0; i < N + 1; i++) {
            A[i] = Integer.parseInt(aStrArray[i]);
        }
        bStrArray = sc.nextLine().split(" ");
        B = new int[N];
        for (int i = 0; i < N; i++) {
            B[i] = Integer.parseInt(bStrArray[i]);
        }

        long tmp = 0;
        long remainingA = A[N];
        long totalEnemy;
        for (int i = N - 1; i >= 0; i--) {
            totalEnemy = A[i] + remainingA;
            if (B[i] >= totalEnemy) {
                tmp += totalEnemy;
                remainingA = 0;
            } else {
                tmp += B[i];
                if (remainingA - B[i] > 0) {
                    remainingA = A[i];
                } else {
                    remainingA = A[i] - (B[i] - remainingA);
                }
            }
        }
        System.out.println(tmp);
    }
} public class Main {
    public static int N = 0;
    public static int[] A;
    public static int[] B;

    public static void main(String[] args) {

        String[] aStrArray;
        String[] bStrArray;

        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        sc.nextLine();

        aStrArray = sc.nextLine().split(" ");
        A = new int[N + 1];
        for (int i = 0; i < N + 1; i++) {
            A[i] = Integer.parseInt(aStrArray[i]);
        }
        bStrArray = sc.nextLine().split(" ");
        B = new int[N];
        for (int i = 0; i < N; i++) {
            B[i] = Integer.parseInt(bStrArray[i]);
        }

        long tmp = 0;
        long remainingA = A[N];
        long totalEnemy;
        for (int i = N - 1; i >= 0; i--) {
            totalEnemy = A[i] + remainingA;
            if (B[i] >= totalEnemy) {
                tmp += totalEnemy;
                remainingA = 0;
            } else {
                tmp += B[i];
                if (remainingA - B[i] > 0) {
                    remainingA = A[i];
                } else {
                    remainingA = A[i] - (B[i] - remainingA);
                }
            }
        }
        System.out.println(tmp);
    }
} Main
import java.util.Scanner;

public class Main {
    public static int N = 0;
    public static int[] A;
    public static int[] B;

    public static void main(String[] args) {

        String[] aStrArray;
        String[] bStrArray;

        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        sc.nextLine();

        aStrArray = sc.nextLine().split(" ");
        A = new int[N + 1];
        for (int i = 0; i < N + 1; i++) {
            A[i] = Integer.parseInt(aStrArray[i]);
        }
        bStrArray = sc.nextLine().split(" ");
        B = new int[N];
        for (int i = 0; i < N; i++) {
            B[i] = Integer.parseInt(bStrArray[i]);
        }

        long tmp = 0;
        long remainingA = A[N];
        long totalEnemy;
        for (int i = N - 1; i >= 0; i--) {
            totalEnemy = A[i] + remainingA;
            if (B[i] >= totalEnemy) {
                tmp += totalEnemy;
                remainingA = 0;
            } else {
                tmp += B[i];
                if (remainingA - B[i] > 0) {
                    remainingA = A[i];
                } else {
                    remainingA = A[i] - (B[i] - remainingA);
                }
            }
        }
        System.out.println(tmp);
    }
}