

import java.util.Scanner;

public class Main {

	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int ar[]=new int[n+1];
		for(int i=0;i<=n;i++)
		{
			ar[i]=scan.nextInt();
		}
		int br[]=new int[n];
		for(int i=0;i<n;i++)
		{
			br[i]=scan.nextInt();
		}
		long ans=0;
		for(int i=0;i<n;i++)
		{
			int cur=br[i];
			int max=Math.min(ar[i],cur);
			ans+=max;
			cur-=max;
			int sec=Math.min(cur,ar[i+1]);
			ar[i+1]=ar[i+1]-sec;
			ans+=sec;
			
		}
		System.out.println(ans);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int ar[]=new int[n+1];
		for(int i=0;i<=n;i++)
		{
			ar[i]=scan.nextInt();
		}
		int br[]=new int[n];
		for(int i=0;i<n;i++)
		{
			br[i]=scan.nextInt();
		}
		long ans=0;
		for(int i=0;i<n;i++)
		{
			int cur=br[i];
			int max=Math.min(ar[i],cur);
			ans+=max;
			cur-=max;
			int sec=Math.min(cur,ar[i+1]);
			ar[i+1]=ar[i+1]-sec;
			ans+=sec;
			
		}
		System.out.println(ans);
	}
} Main public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int ar[]=new int[n+1];
		for(int i=0;i<=n;i++)
		{
			ar[i]=scan.nextInt();
		}
		int br[]=new int[n];
		for(int i=0;i<n;i++)
		{
			br[i]=scan.nextInt();
		}
		long ans=0;
		for(int i=0;i<n;i++)
		{
			int cur=br[i];
			int max=Math.min(ar[i],cur);
			ans+=max;
			cur-=max;
			int sec=Math.min(cur,ar[i+1]);
			ar[i+1]=ar[i+1]-sec;
			ans+=sec;
			
		}
		System.out.println(ans);
	} main {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int ar[]=new int[n+1];
		for(int i=0;i<=n;i++)
		{
			ar[i]=scan.nextInt();
		}
		int br[]=new int[n];
		for(int i=0;i<n;i++)
		{
			br[i]=scan.nextInt();
		}
		long ans=0;
		for(int i=0;i<n;i++)
		{
			int cur=br[i];
			int max=Math.min(ar[i],cur);
			ans+=max;
			cur-=max;
			int sec=Math.min(cur,ar[i+1]);
			ar[i+1]=ar[i+1]-sec;
			ans+=sec;
			
		}
		System.out.println(ans);
	} Scanner scan=new Scanner(System.in); scan new Scanner(System.in) int n=scan.nextInt(); n scan.nextInt() scan.nextInt scan int ar[]=new int[n+1]; ar new int[n+1] n+1 n 1 for(int i=0;i<=n;i++)
		{
			ar[i]=scan.nextInt();
		} int i=0; int i=0; i 0 i<=n i n i++ i++ i {
			ar[i]=scan.nextInt();
		} {
			ar[i]=scan.nextInt();
		} ar[i]=scan.nextInt() ar[i] ar i scan.nextInt() scan.nextInt scan int br[]=new int[n]; br new int[n] n for(int i=0;i<n;i++)
		{
			br[i]=scan.nextInt();
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			br[i]=scan.nextInt();
		} {
			br[i]=scan.nextInt();
		} br[i]=scan.nextInt() br[i] br i scan.nextInt() scan.nextInt scan long ans=0; ans 0 for(int i=0;i<n;i++)
		{
			int cur=br[i];
			int max=Math.min(ar[i],cur);
			ans+=max;
			cur-=max;
			int sec=Math.min(cur,ar[i+1]);
			ar[i+1]=ar[i+1]-sec;
			ans+=sec;
			
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			int cur=br[i];
			int max=Math.min(ar[i],cur);
			ans+=max;
			cur-=max;
			int sec=Math.min(cur,ar[i+1]);
			ar[i+1]=ar[i+1]-sec;
			ans+=sec;
			
		} {
			int cur=br[i];
			int max=Math.min(ar[i],cur);
			ans+=max;
			cur-=max;
			int sec=Math.min(cur,ar[i+1]);
			ar[i+1]=ar[i+1]-sec;
			ans+=sec;
			
		} int cur=br[i]; cur br[i] br i int max=Math.min(ar[i],cur); max Math.min(ar[i],cur) Math.min Math ar[i] ar i cur ans+=max ans max cur-=max cur max int sec=Math.min(cur,ar[i+1]); sec Math.min(cur,ar[i+1]) Math.min Math cur ar[i+1] ar i+1 i 1 ar[i+1]=ar[i+1]-sec ar[i+1] ar i+1 i 1 ar[i+1]-sec ar[i+1] ar i+1 i 1 sec ans+=sec ans sec System.out.println(ans) System.out.println System.out System System.out ans String args[] args public class Main {

	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int ar[]=new int[n+1];
		for(int i=0;i<=n;i++)
		{
			ar[i]=scan.nextInt();
		}
		int br[]=new int[n];
		for(int i=0;i<n;i++)
		{
			br[i]=scan.nextInt();
		}
		long ans=0;
		for(int i=0;i<n;i++)
		{
			int cur=br[i];
			int max=Math.min(ar[i],cur);
			ans+=max;
			cur-=max;
			int sec=Math.min(cur,ar[i+1]);
			ar[i+1]=ar[i+1]-sec;
			ans+=sec;
			
		}
		System.out.println(ans);
	}
} public class Main {

	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int ar[]=new int[n+1];
		for(int i=0;i<=n;i++)
		{
			ar[i]=scan.nextInt();
		}
		int br[]=new int[n];
		for(int i=0;i<n;i++)
		{
			br[i]=scan.nextInt();
		}
		long ans=0;
		for(int i=0;i<n;i++)
		{
			int cur=br[i];
			int max=Math.min(ar[i],cur);
			ans+=max;
			cur-=max;
			int sec=Math.min(cur,ar[i+1]);
			ar[i+1]=ar[i+1]-sec;
			ans+=sec;
			
		}
		System.out.println(ans);
	}
} Main


import java.util.Scanner;

public class Main {

	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int ar[]=new int[n+1];
		for(int i=0;i<=n;i++)
		{
			ar[i]=scan.nextInt();
		}
		int br[]=new int[n];
		for(int i=0;i<n;i++)
		{
			br[i]=scan.nextInt();
		}
		long ans=0;
		for(int i=0;i<n;i++)
		{
			int cur=br[i];
			int max=Math.min(ar[i],cur);
			ans+=max;
			cur-=max;
			int sec=Math.min(cur,ar[i+1]);
			ar[i+1]=ar[i+1]-sec;
			ans+=sec;
			
		}
		System.out.println(ans);
	}
}
