import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] a = new long[N+1];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextLong();
        }
        long tmp = 0L;
        long hunt = 0L;
        for (int i = 0; i < N; i++) {
            long b = sc.nextLong();
            long capa = b + tmp;
            if (a[i] <= capa) {
                if (a[i] <= tmp) {
                    tmp = b;
                } else {
                    tmp = b + tmp - a[i];
                }
                hunt += a[i];
            } else {
                hunt += b + tmp;
                tmp = 0L;
            }
        }
        if (a[N] <= tmp) {
            hunt += a[N];
        } else {
            hunt += tmp;
        }
        System.out.println(hunt);
    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] a = new long[N+1];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextLong();
        }
        long tmp = 0L;
        long hunt = 0L;
        for (int i = 0; i < N; i++) {
            long b = sc.nextLong();
            long capa = b + tmp;
            if (a[i] <= capa) {
                if (a[i] <= tmp) {
                    tmp = b;
                } else {
                    tmp = b + tmp - a[i];
                }
                hunt += a[i];
            } else {
                hunt += b + tmp;
                tmp = 0L;
            }
        }
        if (a[N] <= tmp) {
            hunt += a[N];
        } else {
            hunt += tmp;
        }
        System.out.println(hunt);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] a = new long[N+1];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextLong();
        }
        long tmp = 0L;
        long hunt = 0L;
        for (int i = 0; i < N; i++) {
            long b = sc.nextLong();
            long capa = b + tmp;
            if (a[i] <= capa) {
                if (a[i] <= tmp) {
                    tmp = b;
                } else {
                    tmp = b + tmp - a[i];
                }
                hunt += a[i];
            } else {
                hunt += b + tmp;
                tmp = 0L;
            }
        }
        if (a[N] <= tmp) {
            hunt += a[N];
        } else {
            hunt += tmp;
        }
        System.out.println(hunt);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] a = new long[N+1];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextLong();
        }
        long tmp = 0L;
        long hunt = 0L;
        for (int i = 0; i < N; i++) {
            long b = sc.nextLong();
            long capa = b + tmp;
            if (a[i] <= capa) {
                if (a[i] <= tmp) {
                    tmp = b;
                } else {
                    tmp = b + tmp - a[i];
                }
                hunt += a[i];
            } else {
                hunt += b + tmp;
                tmp = 0L;
            }
        }
        if (a[N] <= tmp) {
            hunt += a[N];
        } else {
            hunt += tmp;
        }
        System.out.println(hunt);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc long[] a = new long[N+1]; a new long[N+1] N+1 N 1 for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextLong();
        } int i = 0; int i = 0; i 0 i < a.length i a.length a a.length i++ i++ i {
            a[i] = sc.nextLong();
        } {
            a[i] = sc.nextLong();
        } a[i] = sc.nextLong() a[i] a i sc.nextLong() sc.nextLong sc long tmp = 0L; tmp 0L long hunt = 0L; hunt 0L for (int i = 0; i < N; i++) {
            long b = sc.nextLong();
            long capa = b + tmp;
            if (a[i] <= capa) {
                if (a[i] <= tmp) {
                    tmp = b;
                } else {
                    tmp = b + tmp - a[i];
                }
                hunt += a[i];
            } else {
                hunt += b + tmp;
                tmp = 0L;
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            long b = sc.nextLong();
            long capa = b + tmp;
            if (a[i] <= capa) {
                if (a[i] <= tmp) {
                    tmp = b;
                } else {
                    tmp = b + tmp - a[i];
                }
                hunt += a[i];
            } else {
                hunt += b + tmp;
                tmp = 0L;
            }
        } {
            long b = sc.nextLong();
            long capa = b + tmp;
            if (a[i] <= capa) {
                if (a[i] <= tmp) {
                    tmp = b;
                } else {
                    tmp = b + tmp - a[i];
                }
                hunt += a[i];
            } else {
                hunt += b + tmp;
                tmp = 0L;
            }
        } long b = sc.nextLong(); b sc.nextLong() sc.nextLong sc long capa = b + tmp; capa b + tmp b tmp if (a[i] <= capa) {
                if (a[i] <= tmp) {
                    tmp = b;
                } else {
                    tmp = b + tmp - a[i];
                }
                hunt += a[i];
            } else {
                hunt += b + tmp;
                tmp = 0L;
            } a[i] <= capa a[i] a i capa {
                if (a[i] <= tmp) {
                    tmp = b;
                } else {
                    tmp = b + tmp - a[i];
                }
                hunt += a[i];
            } if (a[i] <= tmp) {
                    tmp = b;
                } else {
                    tmp = b + tmp - a[i];
                } a[i] <= tmp a[i] a i tmp {
                    tmp = b;
                } tmp = b tmp b {
                    tmp = b + tmp - a[i];
                } tmp = b + tmp - a[i] tmp b + tmp - a[i] b + tmp b tmp a[i] a i hunt += a[i] hunt a[i] a i {
                hunt += b + tmp;
                tmp = 0L;
            } hunt += b + tmp hunt b + tmp b tmp tmp = 0L tmp 0L if (a[N] <= tmp) {
            hunt += a[N];
        } else {
            hunt += tmp;
        } a[N] <= tmp a[N] a N tmp {
            hunt += a[N];
        } hunt += a[N] hunt a[N] a N {
            hunt += tmp;
        } hunt += tmp hunt tmp System.out.println(hunt) System.out.println System.out System System.out hunt String[] args args public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] a = new long[N+1];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextLong();
        }
        long tmp = 0L;
        long hunt = 0L;
        for (int i = 0; i < N; i++) {
            long b = sc.nextLong();
            long capa = b + tmp;
            if (a[i] <= capa) {
                if (a[i] <= tmp) {
                    tmp = b;
                } else {
                    tmp = b + tmp - a[i];
                }
                hunt += a[i];
            } else {
                hunt += b + tmp;
                tmp = 0L;
            }
        }
        if (a[N] <= tmp) {
            hunt += a[N];
        } else {
            hunt += tmp;
        }
        System.out.println(hunt);
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] a = new long[N+1];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextLong();
        }
        long tmp = 0L;
        long hunt = 0L;
        for (int i = 0; i < N; i++) {
            long b = sc.nextLong();
            long capa = b + tmp;
            if (a[i] <= capa) {
                if (a[i] <= tmp) {
                    tmp = b;
                } else {
                    tmp = b + tmp - a[i];
                }
                hunt += a[i];
            } else {
                hunt += b + tmp;
                tmp = 0L;
            }
        }
        if (a[N] <= tmp) {
            hunt += a[N];
        } else {
            hunt += tmp;
        }
        System.out.println(hunt);
    }
} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] a = new long[N+1];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextLong();
        }
        long tmp = 0L;
        long hunt = 0L;
        for (int i = 0; i < N; i++) {
            long b = sc.nextLong();
            long capa = b + tmp;
            if (a[i] <= capa) {
                if (a[i] <= tmp) {
                    tmp = b;
                } else {
                    tmp = b + tmp - a[i];
                }
                hunt += a[i];
            } else {
                hunt += b + tmp;
                tmp = 0L;
            }
        }
        if (a[N] <= tmp) {
            hunt += a[N];
        } else {
            hunt += tmp;
        }
        System.out.println(hunt);
    }
}