import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	PrintWriter out = new PrintWriter(System.out);
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok = new StringTokenizer("");
    String next() throws IOException {
        if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }
        return tok.nextToken();
    }
    int ni() throws IOException { return Integer.parseInt(next()); }
    long nl() throws IOException { return Long.parseLong(next()); }
  
    void solve() throws IOException {
        int n=ni();
        int[]A=new int[n+1];
        for (int x=0;x<=n;x++) A[x]=ni();
        long ans=0;
        for (int x=0;x<n;x++) {
            int p=ni();
            if (A[x]>=p) { ans+=p; continue; }
            p-=A[x];
            ans+=A[x];
            if (A[x+1]>=p) {
                ans+=p;
                A[x+1]-=p;
            }
            else {
                ans+=A[x+1];
                A[x+1]=0;
            }
        }
        System.out.println(ans);
    }
    
    public static void main(String[] args) throws IOException {
        new Main().solve();
    }
} import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java public class Main
{
	PrintWriter out = new PrintWriter(System.out);
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok = new StringTokenizer("");
    String next() throws IOException {
        if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }
        return tok.nextToken();
    }
    int ni() throws IOException { return Integer.parseInt(next()); }
    long nl() throws IOException { return Long.parseLong(next()); }
  
    void solve() throws IOException {
        int n=ni();
        int[]A=new int[n+1];
        for (int x=0;x<=n;x++) A[x]=ni();
        long ans=0;
        for (int x=0;x<n;x++) {
            int p=ni();
            if (A[x]>=p) { ans+=p; continue; }
            p-=A[x];
            ans+=A[x];
            if (A[x+1]>=p) {
                ans+=p;
                A[x+1]-=p;
            }
            else {
                ans+=A[x+1];
                A[x+1]=0;
            }
        }
        System.out.println(ans);
    }
    
    public static void main(String[] args) throws IOException {
        new Main().solve();
    }
} Main PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) StringTokenizer tok = new StringTokenizer(""); tok new StringTokenizer("") String next() throws IOException {
        if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }
        return tok.nextToken();
    } next {
        if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }
        return tok.nextToken();
    } if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); } !tok.hasMoreTokens() tok.hasMoreTokens() tok.hasMoreTokens tok { tok = new StringTokenizer(in.readLine()); } tok = new StringTokenizer(in.readLine()) tok new StringTokenizer(in.readLine()) return tok.nextToken(); tok.nextToken() tok.nextToken tok int ni() throws IOException { return Integer.parseInt(next()); } ni { return Integer.parseInt(next()); } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next long nl() throws IOException { return Long.parseLong(next()); } nl { return Long.parseLong(next()); } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next void solve() throws IOException {
        int n=ni();
        int[]A=new int[n+1];
        for (int x=0;x<=n;x++) A[x]=ni();
        long ans=0;
        for (int x=0;x<n;x++) {
            int p=ni();
            if (A[x]>=p) { ans+=p; continue; }
            p-=A[x];
            ans+=A[x];
            if (A[x+1]>=p) {
                ans+=p;
                A[x+1]-=p;
            }
            else {
                ans+=A[x+1];
                A[x+1]=0;
            }
        }
        System.out.println(ans);
    } solve {
        int n=ni();
        int[]A=new int[n+1];
        for (int x=0;x<=n;x++) A[x]=ni();
        long ans=0;
        for (int x=0;x<n;x++) {
            int p=ni();
            if (A[x]>=p) { ans+=p; continue; }
            p-=A[x];
            ans+=A[x];
            if (A[x+1]>=p) {
                ans+=p;
                A[x+1]-=p;
            }
            else {
                ans+=A[x+1];
                A[x+1]=0;
            }
        }
        System.out.println(ans);
    } int n=ni(); n ni() ni int[]A=new int[n+1]; A new int[n+1] n+1 n 1 for (int x=0;x<=n;x++) A[x]=ni(); int x=0; int x=0; x 0 x<=n x n x++ x++ x A[x]=ni(); A[x]=ni() A[x] A x ni() ni long ans=0; ans 0 for (int x=0;x<n;x++) {
            int p=ni();
            if (A[x]>=p) { ans+=p; continue; }
            p-=A[x];
            ans+=A[x];
            if (A[x+1]>=p) {
                ans+=p;
                A[x+1]-=p;
            }
            else {
                ans+=A[x+1];
                A[x+1]=0;
            }
        } int x=0; int x=0; x 0 x<n x n x++ x++ x {
            int p=ni();
            if (A[x]>=p) { ans+=p; continue; }
            p-=A[x];
            ans+=A[x];
            if (A[x+1]>=p) {
                ans+=p;
                A[x+1]-=p;
            }
            else {
                ans+=A[x+1];
                A[x+1]=0;
            }
        } {
            int p=ni();
            if (A[x]>=p) { ans+=p; continue; }
            p-=A[x];
            ans+=A[x];
            if (A[x+1]>=p) {
                ans+=p;
                A[x+1]-=p;
            }
            else {
                ans+=A[x+1];
                A[x+1]=0;
            }
        } int p=ni(); p ni() ni if (A[x]>=p) { ans+=p; continue; } A[x]>=p A[x] A x p { ans+=p; continue; } ans+=p ans p continue; p-=A[x] p A[x] A x ans+=A[x] ans A[x] A x if (A[x+1]>=p) {
                ans+=p;
                A[x+1]-=p;
            }
            else {
                ans+=A[x+1];
                A[x+1]=0;
            } A[x+1]>=p A[x+1] A x+1 x 1 p {
                ans+=p;
                A[x+1]-=p;
            } ans+=p ans p A[x+1]-=p A[x+1] A x+1 x 1 p {
                ans+=A[x+1];
                A[x+1]=0;
            } ans+=A[x+1] ans A[x+1] A x+1 x 1 A[x+1]=0 A[x+1] A x+1 x 1 0 System.out.println(ans) System.out.println System.out System System.out ans public static void main(String[] args) throws IOException {
        new Main().solve();
    } main {
        new Main().solve();
    } new Main().solve() new Main().solve new Main() String[] args args public class Main
{
	PrintWriter out = new PrintWriter(System.out);
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok = new StringTokenizer("");
    String next() throws IOException {
        if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }
        return tok.nextToken();
    }
    int ni() throws IOException { return Integer.parseInt(next()); }
    long nl() throws IOException { return Long.parseLong(next()); }
  
    void solve() throws IOException {
        int n=ni();
        int[]A=new int[n+1];
        for (int x=0;x<=n;x++) A[x]=ni();
        long ans=0;
        for (int x=0;x<n;x++) {
            int p=ni();
            if (A[x]>=p) { ans+=p; continue; }
            p-=A[x];
            ans+=A[x];
            if (A[x+1]>=p) {
                ans+=p;
                A[x+1]-=p;
            }
            else {
                ans+=A[x+1];
                A[x+1]=0;
            }
        }
        System.out.println(ans);
    }
    
    public static void main(String[] args) throws IOException {
        new Main().solve();
    }
} public class Main
{
	PrintWriter out = new PrintWriter(System.out);
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok = new StringTokenizer("");
    String next() throws IOException {
        if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }
        return tok.nextToken();
    }
    int ni() throws IOException { return Integer.parseInt(next()); }
    long nl() throws IOException { return Long.parseLong(next()); }
  
    void solve() throws IOException {
        int n=ni();
        int[]A=new int[n+1];
        for (int x=0;x<=n;x++) A[x]=ni();
        long ans=0;
        for (int x=0;x<n;x++) {
            int p=ni();
            if (A[x]>=p) { ans+=p; continue; }
            p-=A[x];
            ans+=A[x];
            if (A[x+1]>=p) {
                ans+=p;
                A[x+1]-=p;
            }
            else {
                ans+=A[x+1];
                A[x+1]=0;
            }
        }
        System.out.println(ans);
    }
    
    public static void main(String[] args) throws IOException {
        new Main().solve();
    }
} Main
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	PrintWriter out = new PrintWriter(System.out);
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok = new StringTokenizer("");
    String next() throws IOException {
        if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }
        return tok.nextToken();
    }
    int ni() throws IOException { return Integer.parseInt(next()); }
    long nl() throws IOException { return Long.parseLong(next()); }
  
    void solve() throws IOException {
        int n=ni();
        int[]A=new int[n+1];
        for (int x=0;x<=n;x++) A[x]=ni();
        long ans=0;
        for (int x=0;x<n;x++) {
            int p=ni();
            if (A[x]>=p) { ans+=p; continue; }
            p-=A[x];
            ans+=A[x];
            if (A[x+1]>=p) {
                ans+=p;
                A[x+1]-=p;
            }
            else {
                ans+=A[x+1];
                A[x+1]=0;
            }
        }
        System.out.println(ans);
    }
    
    public static void main(String[] args) throws IOException {
        new Main().solve();
    }
}