
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static int n,m;
    static long dp[]  ,arr[];
    static boolean[] v;
    static LinkedList<Integer>[] adj;
    static int[] ans;

    public static void main(String[] args) throws IOException{
        Reader.init(System.in);
        int n = Reader.nextInt();
        int[] a = new int[n+1];
        int[] b= new int[n+1];
        for (int i = 0 ; i < n+1 ; i++){
            a[i] = Reader.nextInt();
        }
        for (int i = 0; i < n ; i++){
            b[i] =Reader.nextInt();
        }
        long ans = 0;
        for (int i = 0  ; i < n ; i++){
            int min1 = Math.min(a[i],b[i]);
            ans+= min1;
            a[i]-=min1;
            b[i]-=min1;
            int min2 = Math.min(a[i+1],b[i]);
            ans+=min2;
            a[i+1]-=min2;
            b[i]-=min2;
        }
        System.out.println(ans);

    }


}

class TrieNode{

    int[][] next = new int[2][(1000003)*30];
    int[] cnt = new int[(1000003)*30];
    int Idx = 1;
    int value;
    TrieNode[] arr = new TrieNode[2];

    void insert(int n){
        int cur = 0;
        for(int i = 30 - 1; i >= 0; --i) {
            int val = n >> i & 1;
            int nxt = next[val][cur];
            if (nxt == 0)
                nxt = next[val][cur] = Idx++;
            cur = nxt;
            cnt[cur]++;
        }
    }

    int query(int n , int k){
        int num = 0;
        int ans = 0;
        for(int i = 30 - 1; i >= 0; i--) {
            int val = n >> i & 1;
            if (((k >> i) & 1) == 0) {
                if(val==1) {
                    ans += cnt[next[0][num]];
                }
                else{
                    ans += cnt[next[1][num]];
                }
                num = next[val][num];
            }
            else {
                if (val==1) {
                    num = next[0][num];
                }
                else{
                    num = next[1][num];
                }
            }
            if (num == 0) {
                break;
            }
        }
        ans +=cnt[num];
        return ans;
    }

}

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.*; util.* java public class Main {
    static int n,m;
    static long dp[]  ,arr[];
    static boolean[] v;
    static LinkedList<Integer>[] adj;
    static int[] ans;

    public static void main(String[] args) throws IOException{
        Reader.init(System.in);
        int n = Reader.nextInt();
        int[] a = new int[n+1];
        int[] b= new int[n+1];
        for (int i = 0 ; i < n+1 ; i++){
            a[i] = Reader.nextInt();
        }
        for (int i = 0; i < n ; i++){
            b[i] =Reader.nextInt();
        }
        long ans = 0;
        for (int i = 0  ; i < n ; i++){
            int min1 = Math.min(a[i],b[i]);
            ans+= min1;
            a[i]-=min1;
            b[i]-=min1;
            int min2 = Math.min(a[i+1],b[i]);
            ans+=min2;
            a[i+1]-=min2;
            b[i]-=min2;
        }
        System.out.println(ans);

    }


} Main static int n n m; m static long dp[] dp arr[]; arr static boolean[] v; v static LinkedList<Integer>[] adj; adj static int[] ans; ans public static void main(String[] args) throws IOException{
        Reader.init(System.in);
        int n = Reader.nextInt();
        int[] a = new int[n+1];
        int[] b= new int[n+1];
        for (int i = 0 ; i < n+1 ; i++){
            a[i] = Reader.nextInt();
        }
        for (int i = 0; i < n ; i++){
            b[i] =Reader.nextInt();
        }
        long ans = 0;
        for (int i = 0  ; i < n ; i++){
            int min1 = Math.min(a[i],b[i]);
            ans+= min1;
            a[i]-=min1;
            b[i]-=min1;
            int min2 = Math.min(a[i+1],b[i]);
            ans+=min2;
            a[i+1]-=min2;
            b[i]-=min2;
        }
        System.out.println(ans);

    } main {
        Reader.init(System.in);
        int n = Reader.nextInt();
        int[] a = new int[n+1];
        int[] b= new int[n+1];
        for (int i = 0 ; i < n+1 ; i++){
            a[i] = Reader.nextInt();
        }
        for (int i = 0; i < n ; i++){
            b[i] =Reader.nextInt();
        }
        long ans = 0;
        for (int i = 0  ; i < n ; i++){
            int min1 = Math.min(a[i],b[i]);
            ans+= min1;
            a[i]-=min1;
            b[i]-=min1;
            int min2 = Math.min(a[i+1],b[i]);
            ans+=min2;
            a[i+1]-=min2;
            b[i]-=min2;
        }
        System.out.println(ans);

    } Reader.init(System.in) Reader.init Reader System.in System System.in int n = Reader.nextInt(); n Reader.nextInt() Reader.nextInt Reader int[] a = new int[n+1]; a new int[n+1] n+1 n 1 int[] b= new int[n+1]; b new int[n+1] n+1 n 1 for (int i = 0 ; i < n+1 ; i++){
            a[i] = Reader.nextInt();
        } int i = 0 ; int i = 0 ; i 0 i < n+1 i n+1 n 1 i++ i++ i {
            a[i] = Reader.nextInt();
        } {
            a[i] = Reader.nextInt();
        } a[i] = Reader.nextInt() a[i] a i Reader.nextInt() Reader.nextInt Reader for (int i = 0; i < n ; i++){
            b[i] =Reader.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            b[i] =Reader.nextInt();
        } {
            b[i] =Reader.nextInt();
        } b[i] =Reader.nextInt() b[i] b i Reader.nextInt() Reader.nextInt Reader long ans = 0; ans 0 for (int i = 0  ; i < n ; i++){
            int min1 = Math.min(a[i],b[i]);
            ans+= min1;
            a[i]-=min1;
            b[i]-=min1;
            int min2 = Math.min(a[i+1],b[i]);
            ans+=min2;
            a[i+1]-=min2;
            b[i]-=min2;
        } int i = 0  ; int i = 0  ; i 0 i < n i n i++ i++ i {
            int min1 = Math.min(a[i],b[i]);
            ans+= min1;
            a[i]-=min1;
            b[i]-=min1;
            int min2 = Math.min(a[i+1],b[i]);
            ans+=min2;
            a[i+1]-=min2;
            b[i]-=min2;
        } {
            int min1 = Math.min(a[i],b[i]);
            ans+= min1;
            a[i]-=min1;
            b[i]-=min1;
            int min2 = Math.min(a[i+1],b[i]);
            ans+=min2;
            a[i+1]-=min2;
            b[i]-=min2;
        } int min1 = Math.min(a[i],b[i]); min1 Math.min(a[i],b[i]) Math.min Math a[i] a i b[i] b i ans+= min1 ans min1 a[i]-=min1 a[i] a i min1 b[i]-=min1 b[i] b i min1 int min2 = Math.min(a[i+1],b[i]); min2 Math.min(a[i+1],b[i]) Math.min Math a[i+1] a i+1 i 1 b[i] b i ans+=min2 ans min2 a[i+1]-=min2 a[i+1] a i+1 i 1 min2 b[i]-=min2 b[i] b i min2 System.out.println(ans) System.out.println System.out System System.out ans String[] args args class TrieNode{

    int[][] next = new int[2][(1000003)*30];
    int[] cnt = new int[(1000003)*30];
    int Idx = 1;
    int value;
    TrieNode[] arr = new TrieNode[2];

    void insert(int n){
        int cur = 0;
        for(int i = 30 - 1; i >= 0; --i) {
            int val = n >> i & 1;
            int nxt = next[val][cur];
            if (nxt == 0)
                nxt = next[val][cur] = Idx++;
            cur = nxt;
            cnt[cur]++;
        }
    }

    int query(int n , int k){
        int num = 0;
        int ans = 0;
        for(int i = 30 - 1; i >= 0; i--) {
            int val = n >> i & 1;
            if (((k >> i) & 1) == 0) {
                if(val==1) {
                    ans += cnt[next[0][num]];
                }
                else{
                    ans += cnt[next[1][num]];
                }
                num = next[val][num];
            }
            else {
                if (val==1) {
                    num = next[0][num];
                }
                else{
                    num = next[1][num];
                }
            }
            if (num == 0) {
                break;
            }
        }
        ans +=cnt[num];
        return ans;
    }

} TrieNode int[][] next = new int[2][(1000003)*30]; next new int[2][(1000003)*30] 2 (1000003)*30 (1000003) 30 int[] cnt = new int[(1000003)*30]; cnt new int[(1000003)*30] (1000003)*30 (1000003) 30 int Idx = 1; Idx 1 int value; value TrieNode[] arr = new TrieNode[2]; arr new TrieNode[2] 2 void insert(int n){
        int cur = 0;
        for(int i = 30 - 1; i >= 0; --i) {
            int val = n >> i & 1;
            int nxt = next[val][cur];
            if (nxt == 0)
                nxt = next[val][cur] = Idx++;
            cur = nxt;
            cnt[cur]++;
        }
    } insert {
        int cur = 0;
        for(int i = 30 - 1; i >= 0; --i) {
            int val = n >> i & 1;
            int nxt = next[val][cur];
            if (nxt == 0)
                nxt = next[val][cur] = Idx++;
            cur = nxt;
            cnt[cur]++;
        }
    } int cur = 0; cur 0 for(int i = 30 - 1; i >= 0; --i) {
            int val = n >> i & 1;
            int nxt = next[val][cur];
            if (nxt == 0)
                nxt = next[val][cur] = Idx++;
            cur = nxt;
            cnt[cur]++;
        } int i = 30 - 1; int i = 30 - 1; i 30 - 1 30 1 i >= 0 i 0 --i --i i {
            int val = n >> i & 1;
            int nxt = next[val][cur];
            if (nxt == 0)
                nxt = next[val][cur] = Idx++;
            cur = nxt;
            cnt[cur]++;
        } {
            int val = n >> i & 1;
            int nxt = next[val][cur];
            if (nxt == 0)
                nxt = next[val][cur] = Idx++;
            cur = nxt;
            cnt[cur]++;
        } int val = n >> i & 1; val n >> i & 1 n >> i n i 1 int nxt = next[val][cur]; nxt next[val][cur] next[val] next val cur if (nxt == 0)
                nxt = next[val][cur] = Idx++; nxt == 0 nxt 0 nxt = next[val][cur] = Idx++ nxt next[val][cur] = Idx++ next[val][cur] next[val] next val cur Idx++ Idx cur = nxt cur nxt cnt[cur]++ cnt[cur] cnt cur int n n int query(int n , int k){
        int num = 0;
        int ans = 0;
        for(int i = 30 - 1; i >= 0; i--) {
            int val = n >> i & 1;
            if (((k >> i) & 1) == 0) {
                if(val==1) {
                    ans += cnt[next[0][num]];
                }
                else{
                    ans += cnt[next[1][num]];
                }
                num = next[val][num];
            }
            else {
                if (val==1) {
                    num = next[0][num];
                }
                else{
                    num = next[1][num];
                }
            }
            if (num == 0) {
                break;
            }
        }
        ans +=cnt[num];
        return ans;
    } query {
        int num = 0;
        int ans = 0;
        for(int i = 30 - 1; i >= 0; i--) {
            int val = n >> i & 1;
            if (((k >> i) & 1) == 0) {
                if(val==1) {
                    ans += cnt[next[0][num]];
                }
                else{
                    ans += cnt[next[1][num]];
                }
                num = next[val][num];
            }
            else {
                if (val==1) {
                    num = next[0][num];
                }
                else{
                    num = next[1][num];
                }
            }
            if (num == 0) {
                break;
            }
        }
        ans +=cnt[num];
        return ans;
    } int num = 0; num 0 int ans = 0; ans 0 for(int i = 30 - 1; i >= 0; i--) {
            int val = n >> i & 1;
            if (((k >> i) & 1) == 0) {
                if(val==1) {
                    ans += cnt[next[0][num]];
                }
                else{
                    ans += cnt[next[1][num]];
                }
                num = next[val][num];
            }
            else {
                if (val==1) {
                    num = next[0][num];
                }
                else{
                    num = next[1][num];
                }
            }
            if (num == 0) {
                break;
            }
        } int i = 30 - 1; int i = 30 - 1; i 30 - 1 30 1 i >= 0 i 0 i-- i-- i {
            int val = n >> i & 1;
            if (((k >> i) & 1) == 0) {
                if(val==1) {
                    ans += cnt[next[0][num]];
                }
                else{
                    ans += cnt[next[1][num]];
                }
                num = next[val][num];
            }
            else {
                if (val==1) {
                    num = next[0][num];
                }
                else{
                    num = next[1][num];
                }
            }
            if (num == 0) {
                break;
            }
        } {
            int val = n >> i & 1;
            if (((k >> i) & 1) == 0) {
                if(val==1) {
                    ans += cnt[next[0][num]];
                }
                else{
                    ans += cnt[next[1][num]];
                }
                num = next[val][num];
            }
            else {
                if (val==1) {
                    num = next[0][num];
                }
                else{
                    num = next[1][num];
                }
            }
            if (num == 0) {
                break;
            }
        } int val = n >> i & 1; val n >> i & 1 n >> i n i 1 if (((k >> i) & 1) == 0) {
                if(val==1) {
                    ans += cnt[next[0][num]];
                }
                else{
                    ans += cnt[next[1][num]];
                }
                num = next[val][num];
            }
            else {
                if (val==1) {
                    num = next[0][num];
                }
                else{
                    num = next[1][num];
                }
            } ((k >> i) & 1) == 0 ((k >> i) & 1) (k >> i) k i 1 0 {
                if(val==1) {
                    ans += cnt[next[0][num]];
                }
                else{
                    ans += cnt[next[1][num]];
                }
                num = next[val][num];
            } if(val==1) {
                    ans += cnt[next[0][num]];
                }
                else{
                    ans += cnt[next[1][num]];
                } val==1 val 1 {
                    ans += cnt[next[0][num]];
                } ans += cnt[next[0][num]] ans cnt[next[0][num]] cnt next[0][num] next[0] next 0 num {
                    ans += cnt[next[1][num]];
                } ans += cnt[next[1][num]] ans cnt[next[1][num]] cnt next[1][num] next[1] next 1 num num = next[val][num] num next[val][num] next[val] next val num {
                if (val==1) {
                    num = next[0][num];
                }
                else{
                    num = next[1][num];
                }
            } if (val==1) {
                    num = next[0][num];
                }
                else{
                    num = next[1][num];
                } val==1 val 1 {
                    num = next[0][num];
                } num = next[0][num] num next[0][num] next[0] next 0 num {
                    num = next[1][num];
                } num = next[1][num] num next[1][num] next[1] next 1 num if (num == 0) {
                break;
            } num == 0 num 0 {
                break;
            } break; ans +=cnt[num] ans cnt[num] cnt num return ans; ans int n n int k k class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
} Reader static BufferedReader reader; reader static StringTokenizer tokenizer; tokenizer /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    } init {
        reader = new BufferedReader(
                new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    } reader = new BufferedReader(
                new InputStreamReader(input) ) reader new BufferedReader(
                new InputStreamReader(input) ) tokenizer = new StringTokenizer("") tokenizer new StringTokenizer("") InputStream input input /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    } next {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    } while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        } ! tokenizer.hasMoreTokens() tokenizer.hasMoreTokens() tokenizer.hasMoreTokens tokenizer {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        } tokenizer = new StringTokenizer(
                    reader.readLine() ) tokenizer new StringTokenizer(
                    reader.readLine() ) return tokenizer.nextToken(); tokenizer.nextToken() tokenizer.nextToken tokenizer static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    } nextInt {
        return Integer.parseInt( next() );
    } return Integer.parseInt( next() ); Integer.parseInt( next() ) Integer.parseInt Integer next() next static long nextLong() throws IOException {
        return Long.parseLong( next() );
    } nextLong {
        return Long.parseLong( next() );
    } return Long.parseLong( next() ); Long.parseLong( next() ) Long.parseLong Long next() next static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    } nextDouble {
        return Double.parseDouble( next() );
    } return Double.parseDouble( next() ); Double.parseDouble( next() ) Double.parseDouble Double next() next public class Main {
    static int n,m;
    static long dp[]  ,arr[];
    static boolean[] v;
    static LinkedList<Integer>[] adj;
    static int[] ans;

    public static void main(String[] args) throws IOException{
        Reader.init(System.in);
        int n = Reader.nextInt();
        int[] a = new int[n+1];
        int[] b= new int[n+1];
        for (int i = 0 ; i < n+1 ; i++){
            a[i] = Reader.nextInt();
        }
        for (int i = 0; i < n ; i++){
            b[i] =Reader.nextInt();
        }
        long ans = 0;
        for (int i = 0  ; i < n ; i++){
            int min1 = Math.min(a[i],b[i]);
            ans+= min1;
            a[i]-=min1;
            b[i]-=min1;
            int min2 = Math.min(a[i+1],b[i]);
            ans+=min2;
            a[i+1]-=min2;
            b[i]-=min2;
        }
        System.out.println(ans);

    }


} public class Main {
    static int n,m;
    static long dp[]  ,arr[];
    static boolean[] v;
    static LinkedList<Integer>[] adj;
    static int[] ans;

    public static void main(String[] args) throws IOException{
        Reader.init(System.in);
        int n = Reader.nextInt();
        int[] a = new int[n+1];
        int[] b= new int[n+1];
        for (int i = 0 ; i < n+1 ; i++){
            a[i] = Reader.nextInt();
        }
        for (int i = 0; i < n ; i++){
            b[i] =Reader.nextInt();
        }
        long ans = 0;
        for (int i = 0  ; i < n ; i++){
            int min1 = Math.min(a[i],b[i]);
            ans+= min1;
            a[i]-=min1;
            b[i]-=min1;
            int min2 = Math.min(a[i+1],b[i]);
            ans+=min2;
            a[i+1]-=min2;
            b[i]-=min2;
        }
        System.out.println(ans);

    }


} Main

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static int n,m;
    static long dp[]  ,arr[];
    static boolean[] v;
    static LinkedList<Integer>[] adj;
    static int[] ans;

    public static void main(String[] args) throws IOException{
        Reader.init(System.in);
        int n = Reader.nextInt();
        int[] a = new int[n+1];
        int[] b= new int[n+1];
        for (int i = 0 ; i < n+1 ; i++){
            a[i] = Reader.nextInt();
        }
        for (int i = 0; i < n ; i++){
            b[i] =Reader.nextInt();
        }
        long ans = 0;
        for (int i = 0  ; i < n ; i++){
            int min1 = Math.min(a[i],b[i]);
            ans+= min1;
            a[i]-=min1;
            b[i]-=min1;
            int min2 = Math.min(a[i+1],b[i]);
            ans+=min2;
            a[i+1]-=min2;
            b[i]-=min2;
        }
        System.out.println(ans);

    }


}

class TrieNode{

    int[][] next = new int[2][(1000003)*30];
    int[] cnt = new int[(1000003)*30];
    int Idx = 1;
    int value;
    TrieNode[] arr = new TrieNode[2];

    void insert(int n){
        int cur = 0;
        for(int i = 30 - 1; i >= 0; --i) {
            int val = n >> i & 1;
            int nxt = next[val][cur];
            if (nxt == 0)
                nxt = next[val][cur] = Idx++;
            cur = nxt;
            cnt[cur]++;
        }
    }

    int query(int n , int k){
        int num = 0;
        int ans = 0;
        for(int i = 30 - 1; i >= 0; i--) {
            int val = n >> i & 1;
            if (((k >> i) & 1) == 0) {
                if(val==1) {
                    ans += cnt[next[0][num]];
                }
                else{
                    ans += cnt[next[1][num]];
                }
                num = next[val][num];
            }
            else {
                if (val==1) {
                    num = next[0][num];
                }
                else{
                    num = next[1][num];
                }
            }
            if (num == 0) {
                break;
            }
        }
        ans +=cnt[num];
        return ans;
    }

}

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}