import java.util.Scanner;

public class Main{
    
    public static void main (String[] args){
        
        Scanner sc = new Scanner (System.in);
        
        int N = sc.nextInt();
        int[] machi = new int [N+1];
        int[] kougeki = new int [N];
        
        for (int index=0; index<N+1; index++){
            machi[index]=sc.nextInt();
        }
        for (int index=0; index<N; index++){
            kougeki[index]=sc.nextInt();
        }
        
        Long count = 0l;
        
        for (int index=0; index<N+1; index++){
            if (index==0&&machi[index]>kougeki[index]){
                machi[index]=machi[index]-kougeki[index];
                count+=kougeki[index];
                kougeki[index]=0;
            } else if (index==0&&machi[index]<=kougeki[index]){
                count+=machi[index];
                kougeki[index]=kougeki[index]-machi[index];
                machi[index]=0;
            } else if (machi[index]<=kougeki[index-1]){
                count+=machi[index];
                machi[index]=0;
                kougeki[index-1]=0;
            } else {
                count+=kougeki[index-1];
                machi[index]-=kougeki[index-1];
                kougeki[index-1]=0;
                if (index<N){
                    if (machi[index]>kougeki[index]){
                        machi[index]-=kougeki[index];
                        count+=kougeki[index];
                        kougeki[index]=0;
                    } else {
                        count+=machi[index];
                        kougeki[index]=kougeki[index]-machi[index];
                        machi[index]=0;
                    }
                }
            }
        }
        
        System.out.println(count);
    }
} import java.util.Scanner; Scanner java.util public class Main{
    
    public static void main (String[] args){
        
        Scanner sc = new Scanner (System.in);
        
        int N = sc.nextInt();
        int[] machi = new int [N+1];
        int[] kougeki = new int [N];
        
        for (int index=0; index<N+1; index++){
            machi[index]=sc.nextInt();
        }
        for (int index=0; index<N; index++){
            kougeki[index]=sc.nextInt();
        }
        
        Long count = 0l;
        
        for (int index=0; index<N+1; index++){
            if (index==0&&machi[index]>kougeki[index]){
                machi[index]=machi[index]-kougeki[index];
                count+=kougeki[index];
                kougeki[index]=0;
            } else if (index==0&&machi[index]<=kougeki[index]){
                count+=machi[index];
                kougeki[index]=kougeki[index]-machi[index];
                machi[index]=0;
            } else if (machi[index]<=kougeki[index-1]){
                count+=machi[index];
                machi[index]=0;
                kougeki[index-1]=0;
            } else {
                count+=kougeki[index-1];
                machi[index]-=kougeki[index-1];
                kougeki[index-1]=0;
                if (index<N){
                    if (machi[index]>kougeki[index]){
                        machi[index]-=kougeki[index];
                        count+=kougeki[index];
                        kougeki[index]=0;
                    } else {
                        count+=machi[index];
                        kougeki[index]=kougeki[index]-machi[index];
                        machi[index]=0;
                    }
                }
            }
        }
        
        System.out.println(count);
    }
} Main public static void main (String[] args){
        
        Scanner sc = new Scanner (System.in);
        
        int N = sc.nextInt();
        int[] machi = new int [N+1];
        int[] kougeki = new int [N];
        
        for (int index=0; index<N+1; index++){
            machi[index]=sc.nextInt();
        }
        for (int index=0; index<N; index++){
            kougeki[index]=sc.nextInt();
        }
        
        Long count = 0l;
        
        for (int index=0; index<N+1; index++){
            if (index==0&&machi[index]>kougeki[index]){
                machi[index]=machi[index]-kougeki[index];
                count+=kougeki[index];
                kougeki[index]=0;
            } else if (index==0&&machi[index]<=kougeki[index]){
                count+=machi[index];
                kougeki[index]=kougeki[index]-machi[index];
                machi[index]=0;
            } else if (machi[index]<=kougeki[index-1]){
                count+=machi[index];
                machi[index]=0;
                kougeki[index-1]=0;
            } else {
                count+=kougeki[index-1];
                machi[index]-=kougeki[index-1];
                kougeki[index-1]=0;
                if (index<N){
                    if (machi[index]>kougeki[index]){
                        machi[index]-=kougeki[index];
                        count+=kougeki[index];
                        kougeki[index]=0;
                    } else {
                        count+=machi[index];
                        kougeki[index]=kougeki[index]-machi[index];
                        machi[index]=0;
                    }
                }
            }
        }
        
        System.out.println(count);
    } main {
        
        Scanner sc = new Scanner (System.in);
        
        int N = sc.nextInt();
        int[] machi = new int [N+1];
        int[] kougeki = new int [N];
        
        for (int index=0; index<N+1; index++){
            machi[index]=sc.nextInt();
        }
        for (int index=0; index<N; index++){
            kougeki[index]=sc.nextInt();
        }
        
        Long count = 0l;
        
        for (int index=0; index<N+1; index++){
            if (index==0&&machi[index]>kougeki[index]){
                machi[index]=machi[index]-kougeki[index];
                count+=kougeki[index];
                kougeki[index]=0;
            } else if (index==0&&machi[index]<=kougeki[index]){
                count+=machi[index];
                kougeki[index]=kougeki[index]-machi[index];
                machi[index]=0;
            } else if (machi[index]<=kougeki[index-1]){
                count+=machi[index];
                machi[index]=0;
                kougeki[index-1]=0;
            } else {
                count+=kougeki[index-1];
                machi[index]-=kougeki[index-1];
                kougeki[index-1]=0;
                if (index<N){
                    if (machi[index]>kougeki[index]){
                        machi[index]-=kougeki[index];
                        count+=kougeki[index];
                        kougeki[index]=0;
                    } else {
                        count+=machi[index];
                        kougeki[index]=kougeki[index]-machi[index];
                        machi[index]=0;
                    }
                }
            }
        }
        
        System.out.println(count);
    } Scanner sc = new Scanner (System.in); sc new Scanner (System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] machi = new int [N+1]; machi new int [N+1] N+1 N 1 int[] kougeki = new int [N]; kougeki new int [N] N for (int index=0; index<N+1; index++){
            machi[index]=sc.nextInt();
        } int index=0; int index=0; index 0 index<N+1 index N+1 N 1 index++ index++ index {
            machi[index]=sc.nextInt();
        } {
            machi[index]=sc.nextInt();
        } machi[index]=sc.nextInt() machi[index] machi index sc.nextInt() sc.nextInt sc for (int index=0; index<N; index++){
            kougeki[index]=sc.nextInt();
        } int index=0; int index=0; index 0 index<N index N index++ index++ index {
            kougeki[index]=sc.nextInt();
        } {
            kougeki[index]=sc.nextInt();
        } kougeki[index]=sc.nextInt() kougeki[index] kougeki index sc.nextInt() sc.nextInt sc Long count = 0l; count 0l for (int index=0; index<N+1; index++){
            if (index==0&&machi[index]>kougeki[index]){
                machi[index]=machi[index]-kougeki[index];
                count+=kougeki[index];
                kougeki[index]=0;
            } else if (index==0&&machi[index]<=kougeki[index]){
                count+=machi[index];
                kougeki[index]=kougeki[index]-machi[index];
                machi[index]=0;
            } else if (machi[index]<=kougeki[index-1]){
                count+=machi[index];
                machi[index]=0;
                kougeki[index-1]=0;
            } else {
                count+=kougeki[index-1];
                machi[index]-=kougeki[index-1];
                kougeki[index-1]=0;
                if (index<N){
                    if (machi[index]>kougeki[index]){
                        machi[index]-=kougeki[index];
                        count+=kougeki[index];
                        kougeki[index]=0;
                    } else {
                        count+=machi[index];
                        kougeki[index]=kougeki[index]-machi[index];
                        machi[index]=0;
                    }
                }
            }
        } int index=0; int index=0; index 0 index<N+1 index N+1 N 1 index++ index++ index {
            if (index==0&&machi[index]>kougeki[index]){
                machi[index]=machi[index]-kougeki[index];
                count+=kougeki[index];
                kougeki[index]=0;
            } else if (index==0&&machi[index]<=kougeki[index]){
                count+=machi[index];
                kougeki[index]=kougeki[index]-machi[index];
                machi[index]=0;
            } else if (machi[index]<=kougeki[index-1]){
                count+=machi[index];
                machi[index]=0;
                kougeki[index-1]=0;
            } else {
                count+=kougeki[index-1];
                machi[index]-=kougeki[index-1];
                kougeki[index-1]=0;
                if (index<N){
                    if (machi[index]>kougeki[index]){
                        machi[index]-=kougeki[index];
                        count+=kougeki[index];
                        kougeki[index]=0;
                    } else {
                        count+=machi[index];
                        kougeki[index]=kougeki[index]-machi[index];
                        machi[index]=0;
                    }
                }
            }
        } {
            if (index==0&&machi[index]>kougeki[index]){
                machi[index]=machi[index]-kougeki[index];
                count+=kougeki[index];
                kougeki[index]=0;
            } else if (index==0&&machi[index]<=kougeki[index]){
                count+=machi[index];
                kougeki[index]=kougeki[index]-machi[index];
                machi[index]=0;
            } else if (machi[index]<=kougeki[index-1]){
                count+=machi[index];
                machi[index]=0;
                kougeki[index-1]=0;
            } else {
                count+=kougeki[index-1];
                machi[index]-=kougeki[index-1];
                kougeki[index-1]=0;
                if (index<N){
                    if (machi[index]>kougeki[index]){
                        machi[index]-=kougeki[index];
                        count+=kougeki[index];
                        kougeki[index]=0;
                    } else {
                        count+=machi[index];
                        kougeki[index]=kougeki[index]-machi[index];
                        machi[index]=0;
                    }
                }
            }
        } if (index==0&&machi[index]>kougeki[index]){
                machi[index]=machi[index]-kougeki[index];
                count+=kougeki[index];
                kougeki[index]=0;
            } else if (index==0&&machi[index]<=kougeki[index]){
                count+=machi[index];
                kougeki[index]=kougeki[index]-machi[index];
                machi[index]=0;
            } else if (machi[index]<=kougeki[index-1]){
                count+=machi[index];
                machi[index]=0;
                kougeki[index-1]=0;
            } else {
                count+=kougeki[index-1];
                machi[index]-=kougeki[index-1];
                kougeki[index-1]=0;
                if (index<N){
                    if (machi[index]>kougeki[index]){
                        machi[index]-=kougeki[index];
                        count+=kougeki[index];
                        kougeki[index]=0;
                    } else {
                        count+=machi[index];
                        kougeki[index]=kougeki[index]-machi[index];
                        machi[index]=0;
                    }
                }
            } index==0&&machi[index]>kougeki[index] index==0 index 0 machi[index]>kougeki[index] machi[index] machi index kougeki[index] kougeki index {
                machi[index]=machi[index]-kougeki[index];
                count+=kougeki[index];
                kougeki[index]=0;
            } machi[index]=machi[index]-kougeki[index] machi[index] machi index machi[index]-kougeki[index] machi[index] machi index kougeki[index] kougeki index count+=kougeki[index] count kougeki[index] kougeki index kougeki[index]=0 kougeki[index] kougeki index 0 if (index==0&&machi[index]<=kougeki[index]){
                count+=machi[index];
                kougeki[index]=kougeki[index]-machi[index];
                machi[index]=0;
            } else if (machi[index]<=kougeki[index-1]){
                count+=machi[index];
                machi[index]=0;
                kougeki[index-1]=0;
            } else {
                count+=kougeki[index-1];
                machi[index]-=kougeki[index-1];
                kougeki[index-1]=0;
                if (index<N){
                    if (machi[index]>kougeki[index]){
                        machi[index]-=kougeki[index];
                        count+=kougeki[index];
                        kougeki[index]=0;
                    } else {
                        count+=machi[index];
                        kougeki[index]=kougeki[index]-machi[index];
                        machi[index]=0;
                    }
                }
            } index==0&&machi[index]<=kougeki[index] index==0 index 0 machi[index]<=kougeki[index] machi[index] machi index kougeki[index] kougeki index {
                count+=machi[index];
                kougeki[index]=kougeki[index]-machi[index];
                machi[index]=0;
            } count+=machi[index] count machi[index] machi index kougeki[index]=kougeki[index]-machi[index] kougeki[index] kougeki index kougeki[index]-machi[index] kougeki[index] kougeki index machi[index] machi index machi[index]=0 machi[index] machi index 0 if (machi[index]<=kougeki[index-1]){
                count+=machi[index];
                machi[index]=0;
                kougeki[index-1]=0;
            } else {
                count+=kougeki[index-1];
                machi[index]-=kougeki[index-1];
                kougeki[index-1]=0;
                if (index<N){
                    if (machi[index]>kougeki[index]){
                        machi[index]-=kougeki[index];
                        count+=kougeki[index];
                        kougeki[index]=0;
                    } else {
                        count+=machi[index];
                        kougeki[index]=kougeki[index]-machi[index];
                        machi[index]=0;
                    }
                }
            } machi[index]<=kougeki[index-1] machi[index] machi index kougeki[index-1] kougeki index-1 index 1 {
                count+=machi[index];
                machi[index]=0;
                kougeki[index-1]=0;
            } count+=machi[index] count machi[index] machi index machi[index]=0 machi[index] machi index 0 kougeki[index-1]=0 kougeki[index-1] kougeki index-1 index 1 0 {
                count+=kougeki[index-1];
                machi[index]-=kougeki[index-1];
                kougeki[index-1]=0;
                if (index<N){
                    if (machi[index]>kougeki[index]){
                        machi[index]-=kougeki[index];
                        count+=kougeki[index];
                        kougeki[index]=0;
                    } else {
                        count+=machi[index];
                        kougeki[index]=kougeki[index]-machi[index];
                        machi[index]=0;
                    }
                }
            } count+=kougeki[index-1] count kougeki[index-1] kougeki index-1 index 1 machi[index]-=kougeki[index-1] machi[index] machi index kougeki[index-1] kougeki index-1 index 1 kougeki[index-1]=0 kougeki[index-1] kougeki index-1 index 1 0 if (index<N){
                    if (machi[index]>kougeki[index]){
                        machi[index]-=kougeki[index];
                        count+=kougeki[index];
                        kougeki[index]=0;
                    } else {
                        count+=machi[index];
                        kougeki[index]=kougeki[index]-machi[index];
                        machi[index]=0;
                    }
                } index<N index N {
                    if (machi[index]>kougeki[index]){
                        machi[index]-=kougeki[index];
                        count+=kougeki[index];
                        kougeki[index]=0;
                    } else {
                        count+=machi[index];
                        kougeki[index]=kougeki[index]-machi[index];
                        machi[index]=0;
                    }
                } if (machi[index]>kougeki[index]){
                        machi[index]-=kougeki[index];
                        count+=kougeki[index];
                        kougeki[index]=0;
                    } else {
                        count+=machi[index];
                        kougeki[index]=kougeki[index]-machi[index];
                        machi[index]=0;
                    } machi[index]>kougeki[index] machi[index] machi index kougeki[index] kougeki index {
                        machi[index]-=kougeki[index];
                        count+=kougeki[index];
                        kougeki[index]=0;
                    } machi[index]-=kougeki[index] machi[index] machi index kougeki[index] kougeki index count+=kougeki[index] count kougeki[index] kougeki index kougeki[index]=0 kougeki[index] kougeki index 0 {
                        count+=machi[index];
                        kougeki[index]=kougeki[index]-machi[index];
                        machi[index]=0;
                    } count+=machi[index] count machi[index] machi index kougeki[index]=kougeki[index]-machi[index] kougeki[index] kougeki index kougeki[index]-machi[index] kougeki[index] kougeki index machi[index] machi index machi[index]=0 machi[index] machi index 0 System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main{
    
    public static void main (String[] args){
        
        Scanner sc = new Scanner (System.in);
        
        int N = sc.nextInt();
        int[] machi = new int [N+1];
        int[] kougeki = new int [N];
        
        for (int index=0; index<N+1; index++){
            machi[index]=sc.nextInt();
        }
        for (int index=0; index<N; index++){
            kougeki[index]=sc.nextInt();
        }
        
        Long count = 0l;
        
        for (int index=0; index<N+1; index++){
            if (index==0&&machi[index]>kougeki[index]){
                machi[index]=machi[index]-kougeki[index];
                count+=kougeki[index];
                kougeki[index]=0;
            } else if (index==0&&machi[index]<=kougeki[index]){
                count+=machi[index];
                kougeki[index]=kougeki[index]-machi[index];
                machi[index]=0;
            } else if (machi[index]<=kougeki[index-1]){
                count+=machi[index];
                machi[index]=0;
                kougeki[index-1]=0;
            } else {
                count+=kougeki[index-1];
                machi[index]-=kougeki[index-1];
                kougeki[index-1]=0;
                if (index<N){
                    if (machi[index]>kougeki[index]){
                        machi[index]-=kougeki[index];
                        count+=kougeki[index];
                        kougeki[index]=0;
                    } else {
                        count+=machi[index];
                        kougeki[index]=kougeki[index]-machi[index];
                        machi[index]=0;
                    }
                }
            }
        }
        
        System.out.println(count);
    }
} public class Main{
    
    public static void main (String[] args){
        
        Scanner sc = new Scanner (System.in);
        
        int N = sc.nextInt();
        int[] machi = new int [N+1];
        int[] kougeki = new int [N];
        
        for (int index=0; index<N+1; index++){
            machi[index]=sc.nextInt();
        }
        for (int index=0; index<N; index++){
            kougeki[index]=sc.nextInt();
        }
        
        Long count = 0l;
        
        for (int index=0; index<N+1; index++){
            if (index==0&&machi[index]>kougeki[index]){
                machi[index]=machi[index]-kougeki[index];
                count+=kougeki[index];
                kougeki[index]=0;
            } else if (index==0&&machi[index]<=kougeki[index]){
                count+=machi[index];
                kougeki[index]=kougeki[index]-machi[index];
                machi[index]=0;
            } else if (machi[index]<=kougeki[index-1]){
                count+=machi[index];
                machi[index]=0;
                kougeki[index-1]=0;
            } else {
                count+=kougeki[index-1];
                machi[index]-=kougeki[index-1];
                kougeki[index-1]=0;
                if (index<N){
                    if (machi[index]>kougeki[index]){
                        machi[index]-=kougeki[index];
                        count+=kougeki[index];
                        kougeki[index]=0;
                    } else {
                        count+=machi[index];
                        kougeki[index]=kougeki[index]-machi[index];
                        machi[index]=0;
                    }
                }
            }
        }
        
        System.out.println(count);
    }
} Main
import java.util.Scanner;

public class Main{
    
    public static void main (String[] args){
        
        Scanner sc = new Scanner (System.in);
        
        int N = sc.nextInt();
        int[] machi = new int [N+1];
        int[] kougeki = new int [N];
        
        for (int index=0; index<N+1; index++){
            machi[index]=sc.nextInt();
        }
        for (int index=0; index<N; index++){
            kougeki[index]=sc.nextInt();
        }
        
        Long count = 0l;
        
        for (int index=0; index<N+1; index++){
            if (index==0&&machi[index]>kougeki[index]){
                machi[index]=machi[index]-kougeki[index];
                count+=kougeki[index];
                kougeki[index]=0;
            } else if (index==0&&machi[index]<=kougeki[index]){
                count+=machi[index];
                kougeki[index]=kougeki[index]-machi[index];
                machi[index]=0;
            } else if (machi[index]<=kougeki[index-1]){
                count+=machi[index];
                machi[index]=0;
                kougeki[index-1]=0;
            } else {
                count+=kougeki[index-1];
                machi[index]-=kougeki[index-1];
                kougeki[index-1]=0;
                if (index<N){
                    if (machi[index]>kougeki[index]){
                        machi[index]-=kougeki[index];
                        count+=kougeki[index];
                        kougeki[index]=0;
                    } else {
                        count+=machi[index];
                        kougeki[index]=kougeki[index]-machi[index];
                        machi[index]=0;
                    }
                }
            }
        }
        
        System.out.println(count);
    }
}
