import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        long[] a = new long[100005];
        long[] b = new long[100005];
        for(int i = 0; i < n + 1; ++i){
            a[i] = input.nextLong();
        }
        for(int i = 0; i < n; ++i){
            b[i] = input.nextLong();
        }
        long sum = 0;
        for(int i = 0; i < n; ++i){
            if(a[i] <= b[i]){
                sum += a[i];
                b[i] -= a[i];
            }
            else{
                sum += b[i];
                b[i] = 0;
            }
            if(a[i + 1] <= b[i]){
                sum += a[i + 1];
                b[i] -= a[i + 1];
                a[i + 1] = 0;
            }
            else{
                sum += b[i];
                a[i + 1] -= b[i];
                b[i] = 0;
            }
        }
        System.out.println(sum);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        long[] a = new long[100005];
        long[] b = new long[100005];
        for(int i = 0; i < n + 1; ++i){
            a[i] = input.nextLong();
        }
        for(int i = 0; i < n; ++i){
            b[i] = input.nextLong();
        }
        long sum = 0;
        for(int i = 0; i < n; ++i){
            if(a[i] <= b[i]){
                sum += a[i];
                b[i] -= a[i];
            }
            else{
                sum += b[i];
                b[i] = 0;
            }
            if(a[i + 1] <= b[i]){
                sum += a[i + 1];
                b[i] -= a[i + 1];
                a[i + 1] = 0;
            }
            else{
                sum += b[i];
                a[i + 1] -= b[i];
                b[i] = 0;
            }
        }
        System.out.println(sum);
    }
} Main public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        long[] a = new long[100005];
        long[] b = new long[100005];
        for(int i = 0; i < n + 1; ++i){
            a[i] = input.nextLong();
        }
        for(int i = 0; i < n; ++i){
            b[i] = input.nextLong();
        }
        long sum = 0;
        for(int i = 0; i < n; ++i){
            if(a[i] <= b[i]){
                sum += a[i];
                b[i] -= a[i];
            }
            else{
                sum += b[i];
                b[i] = 0;
            }
            if(a[i + 1] <= b[i]){
                sum += a[i + 1];
                b[i] -= a[i + 1];
                a[i + 1] = 0;
            }
            else{
                sum += b[i];
                a[i + 1] -= b[i];
                b[i] = 0;
            }
        }
        System.out.println(sum);
    } main {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        long[] a = new long[100005];
        long[] b = new long[100005];
        for(int i = 0; i < n + 1; ++i){
            a[i] = input.nextLong();
        }
        for(int i = 0; i < n; ++i){
            b[i] = input.nextLong();
        }
        long sum = 0;
        for(int i = 0; i < n; ++i){
            if(a[i] <= b[i]){
                sum += a[i];
                b[i] -= a[i];
            }
            else{
                sum += b[i];
                b[i] = 0;
            }
            if(a[i + 1] <= b[i]){
                sum += a[i + 1];
                b[i] -= a[i + 1];
                a[i + 1] = 0;
            }
            else{
                sum += b[i];
                a[i + 1] -= b[i];
                b[i] = 0;
            }
        }
        System.out.println(sum);
    } Scanner input = new Scanner(System.in); input new Scanner(System.in) int n = input.nextInt(); n input.nextInt() input.nextInt input long[] a = new long[100005]; a new long[100005] 100005 long[] b = new long[100005]; b new long[100005] 100005 for(int i = 0; i < n + 1; ++i){
            a[i] = input.nextLong();
        } int i = 0; int i = 0; i 0 i < n + 1 i n + 1 n 1 ++i ++i i {
            a[i] = input.nextLong();
        } {
            a[i] = input.nextLong();
        } a[i] = input.nextLong() a[i] a i input.nextLong() input.nextLong input for(int i = 0; i < n; ++i){
            b[i] = input.nextLong();
        } int i = 0; int i = 0; i 0 i < n i n ++i ++i i {
            b[i] = input.nextLong();
        } {
            b[i] = input.nextLong();
        } b[i] = input.nextLong() b[i] b i input.nextLong() input.nextLong input long sum = 0; sum 0 for(int i = 0; i < n; ++i){
            if(a[i] <= b[i]){
                sum += a[i];
                b[i] -= a[i];
            }
            else{
                sum += b[i];
                b[i] = 0;
            }
            if(a[i + 1] <= b[i]){
                sum += a[i + 1];
                b[i] -= a[i + 1];
                a[i + 1] = 0;
            }
            else{
                sum += b[i];
                a[i + 1] -= b[i];
                b[i] = 0;
            }
        } int i = 0; int i = 0; i 0 i < n i n ++i ++i i {
            if(a[i] <= b[i]){
                sum += a[i];
                b[i] -= a[i];
            }
            else{
                sum += b[i];
                b[i] = 0;
            }
            if(a[i + 1] <= b[i]){
                sum += a[i + 1];
                b[i] -= a[i + 1];
                a[i + 1] = 0;
            }
            else{
                sum += b[i];
                a[i + 1] -= b[i];
                b[i] = 0;
            }
        } {
            if(a[i] <= b[i]){
                sum += a[i];
                b[i] -= a[i];
            }
            else{
                sum += b[i];
                b[i] = 0;
            }
            if(a[i + 1] <= b[i]){
                sum += a[i + 1];
                b[i] -= a[i + 1];
                a[i + 1] = 0;
            }
            else{
                sum += b[i];
                a[i + 1] -= b[i];
                b[i] = 0;
            }
        } if(a[i] <= b[i]){
                sum += a[i];
                b[i] -= a[i];
            }
            else{
                sum += b[i];
                b[i] = 0;
            } a[i] <= b[i] a[i] a i b[i] b i {
                sum += a[i];
                b[i] -= a[i];
            } sum += a[i] sum a[i] a i b[i] -= a[i] b[i] b i a[i] a i {
                sum += b[i];
                b[i] = 0;
            } sum += b[i] sum b[i] b i b[i] = 0 b[i] b i 0 if(a[i + 1] <= b[i]){
                sum += a[i + 1];
                b[i] -= a[i + 1];
                a[i + 1] = 0;
            }
            else{
                sum += b[i];
                a[i + 1] -= b[i];
                b[i] = 0;
            } a[i + 1] <= b[i] a[i + 1] a i + 1 i 1 b[i] b i {
                sum += a[i + 1];
                b[i] -= a[i + 1];
                a[i + 1] = 0;
            } sum += a[i + 1] sum a[i + 1] a i + 1 i 1 b[i] -= a[i + 1] b[i] b i a[i + 1] a i + 1 i 1 a[i + 1] = 0 a[i + 1] a i + 1 i 1 0 {
                sum += b[i];
                a[i + 1] -= b[i];
                b[i] = 0;
            } sum += b[i] sum b[i] b i a[i + 1] -= b[i] a[i + 1] a i + 1 i 1 b[i] b i b[i] = 0 b[i] b i 0 System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        long[] a = new long[100005];
        long[] b = new long[100005];
        for(int i = 0; i < n + 1; ++i){
            a[i] = input.nextLong();
        }
        for(int i = 0; i < n; ++i){
            b[i] = input.nextLong();
        }
        long sum = 0;
        for(int i = 0; i < n; ++i){
            if(a[i] <= b[i]){
                sum += a[i];
                b[i] -= a[i];
            }
            else{
                sum += b[i];
                b[i] = 0;
            }
            if(a[i + 1] <= b[i]){
                sum += a[i + 1];
                b[i] -= a[i + 1];
                a[i + 1] = 0;
            }
            else{
                sum += b[i];
                a[i + 1] -= b[i];
                b[i] = 0;
            }
        }
        System.out.println(sum);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        long[] a = new long[100005];
        long[] b = new long[100005];
        for(int i = 0; i < n + 1; ++i){
            a[i] = input.nextLong();
        }
        for(int i = 0; i < n; ++i){
            b[i] = input.nextLong();
        }
        long sum = 0;
        for(int i = 0; i < n; ++i){
            if(a[i] <= b[i]){
                sum += a[i];
                b[i] -= a[i];
            }
            else{
                sum += b[i];
                b[i] = 0;
            }
            if(a[i + 1] <= b[i]){
                sum += a[i + 1];
                b[i] -= a[i + 1];
                a[i + 1] = 0;
            }
            else{
                sum += b[i];
                a[i + 1] -= b[i];
                b[i] = 0;
            }
        }
        System.out.println(sum);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        long[] a = new long[100005];
        long[] b = new long[100005];
        for(int i = 0; i < n + 1; ++i){
            a[i] = input.nextLong();
        }
        for(int i = 0; i < n; ++i){
            b[i] = input.nextLong();
        }
        long sum = 0;
        for(int i = 0; i < n; ++i){
            if(a[i] <= b[i]){
                sum += a[i];
                b[i] -= a[i];
            }
            else{
                sum += b[i];
                b[i] = 0;
            }
            if(a[i + 1] <= b[i]){
                sum += a[i + 1];
                b[i] -= a[i + 1];
                a[i + 1] = 0;
            }
            else{
                sum += b[i];
                a[i + 1] -= b[i];
                b[i] = 0;
            }
        }
        System.out.println(sum);
    }
}
