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<N+1;i++) {
            A[i] = sc.nextInt();
        }

        long ans = 0;
        for (int i=0;i<N;i++) {
            int Bi = sc.nextInt();
            if (A[i] >= Bi) {
                ans += Bi;
            } else {
                ans += A[i];
                Bi -= A[i];
                if (A[i+1] >= Bi) {
                    ans += Bi;
                    A[i+1] -= Bi;
                } else {
                    ans += A[i+1];
                    A[i+1] = 0;
                }
            }
        }
        System.out.println(ans);
    }
} 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<N+1;i++) {
            A[i] = sc.nextInt();
        }

        long ans = 0;
        for (int i=0;i<N;i++) {
            int Bi = sc.nextInt();
            if (A[i] >= Bi) {
                ans += Bi;
            } else {
                ans += A[i];
                Bi -= A[i];
                if (A[i+1] >= Bi) {
                    ans += Bi;
                    A[i+1] -= Bi;
                } else {
                    ans += A[i+1];
                    A[i+1] = 0;
                }
            }
        }
        System.out.println(ans);
    }
} 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<N+1;i++) {
            A[i] = sc.nextInt();
        }

        long ans = 0;
        for (int i=0;i<N;i++) {
            int Bi = sc.nextInt();
            if (A[i] >= Bi) {
                ans += Bi;
            } else {
                ans += A[i];
                Bi -= A[i];
                if (A[i+1] >= Bi) {
                    ans += Bi;
                    A[i+1] -= Bi;
                } else {
                    ans += A[i+1];
                    A[i+1] = 0;
                }
            }
        }
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A[] = new int[N+1];

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

        long ans = 0;
        for (int i=0;i<N;i++) {
            int Bi = sc.nextInt();
            if (A[i] >= Bi) {
                ans += Bi;
            } else {
                ans += A[i];
                Bi -= A[i];
                if (A[i+1] >= Bi) {
                    ans += Bi;
                    A[i+1] -= Bi;
                } else {
                    ans += A[i+1];
                    A[i+1] = 0;
                }
            }
        }
        System.out.println(ans);
    } 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<N+1;i++) {
            A[i] = sc.nextInt();
        } int i=0; int i=0; i 0 i<N+1 i N+1 N 1 i++ i++ i {
            A[i] = sc.nextInt();
        } {
            A[i] = sc.nextInt();
        } A[i] = sc.nextInt() A[i] A i sc.nextInt() sc.nextInt sc long ans = 0; ans 0 for (int i=0;i<N;i++) {
            int Bi = sc.nextInt();
            if (A[i] >= Bi) {
                ans += Bi;
            } else {
                ans += A[i];
                Bi -= A[i];
                if (A[i+1] >= Bi) {
                    ans += Bi;
                    A[i+1] -= Bi;
                } else {
                    ans += A[i+1];
                    A[i+1] = 0;
                }
            }
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            int Bi = sc.nextInt();
            if (A[i] >= Bi) {
                ans += Bi;
            } else {
                ans += A[i];
                Bi -= A[i];
                if (A[i+1] >= Bi) {
                    ans += Bi;
                    A[i+1] -= Bi;
                } else {
                    ans += A[i+1];
                    A[i+1] = 0;
                }
            }
        } {
            int Bi = sc.nextInt();
            if (A[i] >= Bi) {
                ans += Bi;
            } else {
                ans += A[i];
                Bi -= A[i];
                if (A[i+1] >= Bi) {
                    ans += Bi;
                    A[i+1] -= Bi;
                } else {
                    ans += A[i+1];
                    A[i+1] = 0;
                }
            }
        } int Bi = sc.nextInt(); Bi sc.nextInt() sc.nextInt sc if (A[i] >= Bi) {
                ans += Bi;
            } else {
                ans += A[i];
                Bi -= A[i];
                if (A[i+1] >= Bi) {
                    ans += Bi;
                    A[i+1] -= Bi;
                } else {
                    ans += A[i+1];
                    A[i+1] = 0;
                }
            } A[i] >= Bi A[i] A i Bi {
                ans += Bi;
            } ans += Bi ans Bi {
                ans += A[i];
                Bi -= A[i];
                if (A[i+1] >= Bi) {
                    ans += Bi;
                    A[i+1] -= Bi;
                } else {
                    ans += A[i+1];
                    A[i+1] = 0;
                }
            } ans += A[i] ans A[i] A i Bi -= A[i] Bi A[i] A i if (A[i+1] >= Bi) {
                    ans += Bi;
                    A[i+1] -= Bi;
                } else {
                    ans += A[i+1];
                    A[i+1] = 0;
                } A[i+1] >= Bi A[i+1] A i+1 i 1 Bi {
                    ans += Bi;
                    A[i+1] -= Bi;
                } ans += Bi ans Bi A[i+1] -= Bi A[i+1] A i+1 i 1 Bi {
                    ans += A[i+1];
                    A[i+1] = 0;
                } ans += A[i+1] ans A[i+1] A i+1 i 1 A[i+1] = 0 A[i+1] A i+1 i 1 0 System.out.println(ans) System.out.println System.out System System.out ans String[] args args 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<N+1;i++) {
            A[i] = sc.nextInt();
        }

        long ans = 0;
        for (int i=0;i<N;i++) {
            int Bi = sc.nextInt();
            if (A[i] >= Bi) {
                ans += Bi;
            } else {
                ans += A[i];
                Bi -= A[i];
                if (A[i+1] >= Bi) {
                    ans += Bi;
                    A[i+1] -= Bi;
                } else {
                    ans += A[i+1];
                    A[i+1] = 0;
                }
            }
        }
        System.out.println(ans);
    }
} 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<N+1;i++) {
            A[i] = sc.nextInt();
        }

        long ans = 0;
        for (int i=0;i<N;i++) {
            int Bi = sc.nextInt();
            if (A[i] >= Bi) {
                ans += Bi;
            } else {
                ans += A[i];
                Bi -= A[i];
                if (A[i+1] >= Bi) {
                    ans += Bi;
                    A[i+1] -= Bi;
                } else {
                    ans += A[i+1];
                    A[i+1] = 0;
                }
            }
        }
        System.out.println(ans);
    }
} 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 A[] = new int[N+1];

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

        long ans = 0;
        for (int i=0;i<N;i++) {
            int Bi = sc.nextInt();
            if (A[i] >= Bi) {
                ans += Bi;
            } else {
                ans += A[i];
                Bi -= A[i];
                if (A[i+1] >= Bi) {
                    ans += Bi;
                    A[i+1] -= Bi;
                } else {
                    ans += A[i+1];
                    A[i+1] = 0;
                }
            }
        }
        System.out.println(ans);
    }
}
