import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int[] a = new int[n+1];
        int[] b = new int[n];
        for(int i = 0;i<a.length;i++) {
            a[i] = stdIn.nextInt();
        }
        for(int i = 0;i<b.length;i++) {
            b[i] = stdIn.nextInt();
        }
        long count = 0;
        for(int i = 0;i<b.length;i++) {
            if(a[i]>=b[i]) {
                count += b[i];
                a[i] -= b[i];
                b[i]  = 0;
            } else {
                count += a[i];
                b[i] -= a[i];
                a[i] = 0;
            }
            if(a[i+1]>=b[i]) {
                count += b[i];
                a[i+1] -= b[i];
                b[i] = 0;
            } else {
                count += a[i+1];
                b[i] -=a[i+1];
                a[i+1] = 0;
            }
        }
        System.out.println(count);
    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int[] a = new int[n+1];
        int[] b = new int[n];
        for(int i = 0;i<a.length;i++) {
            a[i] = stdIn.nextInt();
        }
        for(int i = 0;i<b.length;i++) {
            b[i] = stdIn.nextInt();
        }
        long count = 0;
        for(int i = 0;i<b.length;i++) {
            if(a[i]>=b[i]) {
                count += b[i];
                a[i] -= b[i];
                b[i]  = 0;
            } else {
                count += a[i];
                b[i] -= a[i];
                a[i] = 0;
            }
            if(a[i+1]>=b[i]) {
                count += b[i];
                a[i+1] -= b[i];
                b[i] = 0;
            } else {
                count += a[i+1];
                b[i] -=a[i+1];
                a[i+1] = 0;
            }
        }
        System.out.println(count);
    }
} Main public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int[] a = new int[n+1];
        int[] b = new int[n];
        for(int i = 0;i<a.length;i++) {
            a[i] = stdIn.nextInt();
        }
        for(int i = 0;i<b.length;i++) {
            b[i] = stdIn.nextInt();
        }
        long count = 0;
        for(int i = 0;i<b.length;i++) {
            if(a[i]>=b[i]) {
                count += b[i];
                a[i] -= b[i];
                b[i]  = 0;
            } else {
                count += a[i];
                b[i] -= a[i];
                a[i] = 0;
            }
            if(a[i+1]>=b[i]) {
                count += b[i];
                a[i+1] -= b[i];
                b[i] = 0;
            } else {
                count += a[i+1];
                b[i] -=a[i+1];
                a[i+1] = 0;
            }
        }
        System.out.println(count);
    } main {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int[] a = new int[n+1];
        int[] b = new int[n];
        for(int i = 0;i<a.length;i++) {
            a[i] = stdIn.nextInt();
        }
        for(int i = 0;i<b.length;i++) {
            b[i] = stdIn.nextInt();
        }
        long count = 0;
        for(int i = 0;i<b.length;i++) {
            if(a[i]>=b[i]) {
                count += b[i];
                a[i] -= b[i];
                b[i]  = 0;
            } else {
                count += a[i];
                b[i] -= a[i];
                a[i] = 0;
            }
            if(a[i+1]>=b[i]) {
                count += b[i];
                a[i+1] -= b[i];
                b[i] = 0;
            } else {
                count += a[i+1];
                b[i] -=a[i+1];
                a[i+1] = 0;
            }
        }
        System.out.println(count);
    } Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int n = stdIn.nextInt(); n stdIn.nextInt() stdIn.nextInt stdIn int[] a = new int[n+1]; a new int[n+1] n+1 n 1 int[] b = new int[n]; b new int[n] n for(int i = 0;i<a.length;i++) {
            a[i] = stdIn.nextInt();
        } int i = 0; int i = 0; i 0 i<a.length i a.length a a.length i++ i++ i {
            a[i] = stdIn.nextInt();
        } {
            a[i] = stdIn.nextInt();
        } a[i] = stdIn.nextInt() a[i] a i stdIn.nextInt() stdIn.nextInt stdIn for(int i = 0;i<b.length;i++) {
            b[i] = stdIn.nextInt();
        } int i = 0; int i = 0; i 0 i<b.length i b.length b b.length i++ i++ i {
            b[i] = stdIn.nextInt();
        } {
            b[i] = stdIn.nextInt();
        } b[i] = stdIn.nextInt() b[i] b i stdIn.nextInt() stdIn.nextInt stdIn long count = 0; count 0 for(int i = 0;i<b.length;i++) {
            if(a[i]>=b[i]) {
                count += b[i];
                a[i] -= b[i];
                b[i]  = 0;
            } else {
                count += a[i];
                b[i] -= a[i];
                a[i] = 0;
            }
            if(a[i+1]>=b[i]) {
                count += b[i];
                a[i+1] -= b[i];
                b[i] = 0;
            } else {
                count += a[i+1];
                b[i] -=a[i+1];
                a[i+1] = 0;
            }
        } int i = 0; int i = 0; i 0 i<b.length i b.length b b.length i++ i++ i {
            if(a[i]>=b[i]) {
                count += b[i];
                a[i] -= b[i];
                b[i]  = 0;
            } else {
                count += a[i];
                b[i] -= a[i];
                a[i] = 0;
            }
            if(a[i+1]>=b[i]) {
                count += b[i];
                a[i+1] -= b[i];
                b[i] = 0;
            } else {
                count += a[i+1];
                b[i] -=a[i+1];
                a[i+1] = 0;
            }
        } {
            if(a[i]>=b[i]) {
                count += b[i];
                a[i] -= b[i];
                b[i]  = 0;
            } else {
                count += a[i];
                b[i] -= a[i];
                a[i] = 0;
            }
            if(a[i+1]>=b[i]) {
                count += b[i];
                a[i+1] -= b[i];
                b[i] = 0;
            } else {
                count += a[i+1];
                b[i] -=a[i+1];
                a[i+1] = 0;
            }
        } if(a[i]>=b[i]) {
                count += b[i];
                a[i] -= b[i];
                b[i]  = 0;
            } else {
                count += a[i];
                b[i] -= a[i];
                a[i] = 0;
            } a[i]>=b[i] a[i] a i b[i] b i {
                count += b[i];
                a[i] -= b[i];
                b[i]  = 0;
            } count += b[i] count b[i] b i a[i] -= b[i] a[i] a i b[i] b i b[i]  = 0 b[i] b i 0 {
                count += a[i];
                b[i] -= a[i];
                a[i] = 0;
            } count += a[i] count a[i] a i b[i] -= a[i] b[i] b i a[i] a i a[i] = 0 a[i] a i 0 if(a[i+1]>=b[i]) {
                count += b[i];
                a[i+1] -= b[i];
                b[i] = 0;
            } else {
                count += a[i+1];
                b[i] -=a[i+1];
                a[i+1] = 0;
            } a[i+1]>=b[i] a[i+1] a i+1 i 1 b[i] b i {
                count += b[i];
                a[i+1] -= b[i];
                b[i] = 0;
            } count += b[i] count 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 {
                count += a[i+1];
                b[i] -=a[i+1];
                a[i+1] = 0;
            } count += a[i+1] count 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 System.out.println(count) System.out.println System.out System System.out count String[] args args
import java.util.*;

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