import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main {
        public static void main(String[] args) throws Exception {
                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                StringTokenizer st;
                int n = Integer.parseInt(br.readLine());
                st = new StringTokenizer(br.readLine());
                int a[] = new int[n+1];
                for(int i=0 ; i<n+1 ; i++) {
                        a[i] = Integer.parseInt(st.nextToken());
                }

                st = new StringTokenizer(br.readLine());
                int b[] = new int[n];
                long count = 0;
                for(int i=0 ; i<n ; i++) {
                        b[i] = Integer.parseInt(st.nextToken());
                        if(a[i] >= b[i]) {
                                count += b[i];
                                a[i] -= b[i];
                                b[i] = 0;
                        }
                        else {
                                b[i] -= a[i];
                                count += a[i];
                                a[i] = 0;
                                if(a[i+1] >= b[i]) {
                                        count += b[i];
                                        a[i+1] -= b[i];
                                        b[i] = 0;
                                }
                                else {
                                        b[i] -= a[i+1];
                                        count += a[i+1];
                                        a[i+1] = 0;
                                }
                        }
                }

                System.out.println(count);
        }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.StringTokenizer; StringTokenizer java.util class Main {
        public static void main(String[] args) throws Exception {
                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                StringTokenizer st;
                int n = Integer.parseInt(br.readLine());
                st = new StringTokenizer(br.readLine());
                int a[] = new int[n+1];
                for(int i=0 ; i<n+1 ; i++) {
                        a[i] = Integer.parseInt(st.nextToken());
                }

                st = new StringTokenizer(br.readLine());
                int b[] = new int[n];
                long count = 0;
                for(int i=0 ; i<n ; i++) {
                        b[i] = Integer.parseInt(st.nextToken());
                        if(a[i] >= b[i]) {
                                count += b[i];
                                a[i] -= b[i];
                                b[i] = 0;
                        }
                        else {
                                b[i] -= a[i];
                                count += a[i];
                                a[i] = 0;
                                if(a[i+1] >= b[i]) {
                                        count += b[i];
                                        a[i+1] -= b[i];
                                        b[i] = 0;
                                }
                                else {
                                        b[i] -= a[i+1];
                                        count += a[i+1];
                                        a[i+1] = 0;
                                }
                        }
                }

                System.out.println(count);
        }
} Main public static void main(String[] args) throws Exception {
                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                StringTokenizer st;
                int n = Integer.parseInt(br.readLine());
                st = new StringTokenizer(br.readLine());
                int a[] = new int[n+1];
                for(int i=0 ; i<n+1 ; i++) {
                        a[i] = Integer.parseInt(st.nextToken());
                }

                st = new StringTokenizer(br.readLine());
                int b[] = new int[n];
                long count = 0;
                for(int i=0 ; i<n ; i++) {
                        b[i] = Integer.parseInt(st.nextToken());
                        if(a[i] >= b[i]) {
                                count += b[i];
                                a[i] -= b[i];
                                b[i] = 0;
                        }
                        else {
                                b[i] -= a[i];
                                count += a[i];
                                a[i] = 0;
                                if(a[i+1] >= b[i]) {
                                        count += b[i];
                                        a[i+1] -= b[i];
                                        b[i] = 0;
                                }
                                else {
                                        b[i] -= a[i+1];
                                        count += a[i+1];
                                        a[i+1] = 0;
                                }
                        }
                }

                System.out.println(count);
        } main {
                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                StringTokenizer st;
                int n = Integer.parseInt(br.readLine());
                st = new StringTokenizer(br.readLine());
                int a[] = new int[n+1];
                for(int i=0 ; i<n+1 ; i++) {
                        a[i] = Integer.parseInt(st.nextToken());
                }

                st = new StringTokenizer(br.readLine());
                int b[] = new int[n];
                long count = 0;
                for(int i=0 ; i<n ; i++) {
                        b[i] = Integer.parseInt(st.nextToken());
                        if(a[i] >= b[i]) {
                                count += b[i];
                                a[i] -= b[i];
                                b[i] = 0;
                        }
                        else {
                                b[i] -= a[i];
                                count += a[i];
                                a[i] = 0;
                                if(a[i+1] >= b[i]) {
                                        count += b[i];
                                        a[i+1] -= b[i];
                                        b[i] = 0;
                                }
                                else {
                                        b[i] -= a[i+1];
                                        count += a[i+1];
                                        a[i+1] = 0;
                                }
                        }
                }

                System.out.println(count);
        } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringTokenizer st; st int n = Integer.parseInt(br.readLine()); n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) 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] = Integer.parseInt(st.nextToken());
                } int i=0 ; int i=0 ; i 0 i<n+1 i n+1 n 1 i++ i++ i {
                        a[i] = Integer.parseInt(st.nextToken());
                } {
                        a[i] = Integer.parseInt(st.nextToken());
                } a[i] = Integer.parseInt(st.nextToken()) a[i] a i Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) int b[] = new int[n]; b new int[n] n long count = 0; count 0 for(int i=0 ; i<n ; i++) {
                        b[i] = Integer.parseInt(st.nextToken());
                        if(a[i] >= b[i]) {
                                count += b[i];
                                a[i] -= b[i];
                                b[i] = 0;
                        }
                        else {
                                b[i] -= a[i];
                                count += a[i];
                                a[i] = 0;
                                if(a[i+1] >= b[i]) {
                                        count += b[i];
                                        a[i+1] -= b[i];
                                        b[i] = 0;
                                }
                                else {
                                        b[i] -= a[i+1];
                                        count += a[i+1];
                                        a[i+1] = 0;
                                }
                        }
                } int i=0 ; int i=0 ; i 0 i<n i n i++ i++ i {
                        b[i] = Integer.parseInt(st.nextToken());
                        if(a[i] >= b[i]) {
                                count += b[i];
                                a[i] -= b[i];
                                b[i] = 0;
                        }
                        else {
                                b[i] -= a[i];
                                count += a[i];
                                a[i] = 0;
                                if(a[i+1] >= b[i]) {
                                        count += b[i];
                                        a[i+1] -= b[i];
                                        b[i] = 0;
                                }
                                else {
                                        b[i] -= a[i+1];
                                        count += a[i+1];
                                        a[i+1] = 0;
                                }
                        }
                } {
                        b[i] = Integer.parseInt(st.nextToken());
                        if(a[i] >= b[i]) {
                                count += b[i];
                                a[i] -= b[i];
                                b[i] = 0;
                        }
                        else {
                                b[i] -= a[i];
                                count += a[i];
                                a[i] = 0;
                                if(a[i+1] >= b[i]) {
                                        count += b[i];
                                        a[i+1] -= b[i];
                                        b[i] = 0;
                                }
                                else {
                                        b[i] -= a[i+1];
                                        count += a[i+1];
                                        a[i+1] = 0;
                                }
                        }
                } b[i] = Integer.parseInt(st.nextToken()) b[i] b i Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st if(a[i] >= b[i]) {
                                count += b[i];
                                a[i] -= b[i];
                                b[i] = 0;
                        }
                        else {
                                b[i] -= a[i];
                                count += a[i];
                                a[i] = 0;
                                if(a[i+1] >= b[i]) {
                                        count += b[i];
                                        a[i+1] -= b[i];
                                        b[i] = 0;
                                }
                                else {
                                        b[i] -= a[i+1];
                                        count += a[i+1];
                                        a[i+1] = 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 {
                                b[i] -= a[i];
                                count += a[i];
                                a[i] = 0;
                                if(a[i+1] >= b[i]) {
                                        count += b[i];
                                        a[i+1] -= b[i];
                                        b[i] = 0;
                                }
                                else {
                                        b[i] -= a[i+1];
                                        count += a[i+1];
                                        a[i+1] = 0;
                                }
                        } b[i] -= a[i] b[i] b i a[i] a i count += a[i] count 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 {
                                        b[i] -= a[i+1];
                                        count += 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 {
                                        b[i] -= a[i+1];
                                        count += a[i+1];
                                        a[i+1] = 0;
                                } b[i] -= a[i+1] b[i] b i a[i+1] a i+1 i 1 count += a[i+1] count 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.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main {
        public static void main(String[] args) throws Exception {
                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                StringTokenizer st;
                int n = Integer.parseInt(br.readLine());
                st = new StringTokenizer(br.readLine());
                int a[] = new int[n+1];
                for(int i=0 ; i<n+1 ; i++) {
                        a[i] = Integer.parseInt(st.nextToken());
                }

                st = new StringTokenizer(br.readLine());
                int b[] = new int[n];
                long count = 0;
                for(int i=0 ; i<n ; i++) {
                        b[i] = Integer.parseInt(st.nextToken());
                        if(a[i] >= b[i]) {
                                count += b[i];
                                a[i] -= b[i];
                                b[i] = 0;
                        }
                        else {
                                b[i] -= a[i];
                                count += a[i];
                                a[i] = 0;
                                if(a[i+1] >= b[i]) {
                                        count += b[i];
                                        a[i+1] -= b[i];
                                        b[i] = 0;
                                }
                                else {
                                        b[i] -= a[i+1];
                                        count += a[i+1];
                                        a[i+1] = 0;
                                }
                        }
                }

                System.out.println(count);
        }
}
