import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String args[])
	{
		Scanner x=new Scanner(System.in);
    	int n=x.nextInt();
		long c=0;
    	long a[]=new long[n+1];
		long b[]=new long[n];
		for(int i=0;i<n+1;i++)
		{
			a[i]=x.nextLong();
		}
		for(int i=0;i<n;i++)
		{
			b[i]=x.nextLong();
		}
		for(int i=0;i<n;i++)
		{
			c+=Math.min((a[i]+a[i+1]),b[i]);
			if(a[i]<b[i])
			{	
				b[i] -= a[i];
				if(a[i+1]>=b[i])
				{
				a[i+1]-=b[i];
				}
				else
				{
				a[i+1]=0;
				}
			}
		}
		System.out.println(c);
	}
} import java.io.*; io.* java import java.util.*; util.* java public class Main
{
	public static void main(String args[])
	{
		Scanner x=new Scanner(System.in);
    	int n=x.nextInt();
		long c=0;
    	long a[]=new long[n+1];
		long b[]=new long[n];
		for(int i=0;i<n+1;i++)
		{
			a[i]=x.nextLong();
		}
		for(int i=0;i<n;i++)
		{
			b[i]=x.nextLong();
		}
		for(int i=0;i<n;i++)
		{
			c+=Math.min((a[i]+a[i+1]),b[i]);
			if(a[i]<b[i])
			{	
				b[i] -= a[i];
				if(a[i+1]>=b[i])
				{
				a[i+1]-=b[i];
				}
				else
				{
				a[i+1]=0;
				}
			}
		}
		System.out.println(c);
	}
} Main public static void main(String args[])
	{
		Scanner x=new Scanner(System.in);
    	int n=x.nextInt();
		long c=0;
    	long a[]=new long[n+1];
		long b[]=new long[n];
		for(int i=0;i<n+1;i++)
		{
			a[i]=x.nextLong();
		}
		for(int i=0;i<n;i++)
		{
			b[i]=x.nextLong();
		}
		for(int i=0;i<n;i++)
		{
			c+=Math.min((a[i]+a[i+1]),b[i]);
			if(a[i]<b[i])
			{	
				b[i] -= a[i];
				if(a[i+1]>=b[i])
				{
				a[i+1]-=b[i];
				}
				else
				{
				a[i+1]=0;
				}
			}
		}
		System.out.println(c);
	} main {
		Scanner x=new Scanner(System.in);
    	int n=x.nextInt();
		long c=0;
    	long a[]=new long[n+1];
		long b[]=new long[n];
		for(int i=0;i<n+1;i++)
		{
			a[i]=x.nextLong();
		}
		for(int i=0;i<n;i++)
		{
			b[i]=x.nextLong();
		}
		for(int i=0;i<n;i++)
		{
			c+=Math.min((a[i]+a[i+1]),b[i]);
			if(a[i]<b[i])
			{	
				b[i] -= a[i];
				if(a[i+1]>=b[i])
				{
				a[i+1]-=b[i];
				}
				else
				{
				a[i+1]=0;
				}
			}
		}
		System.out.println(c);
	} Scanner x=new Scanner(System.in); x new Scanner(System.in) int n=x.nextInt(); n x.nextInt() x.nextInt x long c=0; c 0 long a[]=new long[n+1]; a new long[n+1] n+1 n 1 long b[]=new long[n]; b new long[n] n for(int i=0;i<n+1;i++)
		{
			a[i]=x.nextLong();
		} int i=0; int i=0; i 0 i<n+1 i n+1 n 1 i++ i++ i {
			a[i]=x.nextLong();
		} {
			a[i]=x.nextLong();
		} a[i]=x.nextLong() a[i] a i x.nextLong() x.nextLong x for(int i=0;i<n;i++)
		{
			b[i]=x.nextLong();
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			b[i]=x.nextLong();
		} {
			b[i]=x.nextLong();
		} b[i]=x.nextLong() b[i] b i x.nextLong() x.nextLong x for(int i=0;i<n;i++)
		{
			c+=Math.min((a[i]+a[i+1]),b[i]);
			if(a[i]<b[i])
			{	
				b[i] -= a[i];
				if(a[i+1]>=b[i])
				{
				a[i+1]-=b[i];
				}
				else
				{
				a[i+1]=0;
				}
			}
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			c+=Math.min((a[i]+a[i+1]),b[i]);
			if(a[i]<b[i])
			{	
				b[i] -= a[i];
				if(a[i+1]>=b[i])
				{
				a[i+1]-=b[i];
				}
				else
				{
				a[i+1]=0;
				}
			}
		} {
			c+=Math.min((a[i]+a[i+1]),b[i]);
			if(a[i]<b[i])
			{	
				b[i] -= a[i];
				if(a[i+1]>=b[i])
				{
				a[i+1]-=b[i];
				}
				else
				{
				a[i+1]=0;
				}
			}
		} c+=Math.min((a[i]+a[i+1]),b[i]) c Math.min((a[i]+a[i+1]),b[i]) Math.min Math (a[i]+a[i+1]) a[i] a i a[i+1] a i+1 i 1 b[i] b i if(a[i]<b[i])
			{	
				b[i] -= a[i];
				if(a[i+1]>=b[i])
				{
				a[i+1]-=b[i];
				}
				else
				{
				a[i+1]=0;
				}
			} a[i]<b[i] a[i] a i b[i] b i {	
				b[i] -= a[i];
				if(a[i+1]>=b[i])
				{
				a[i+1]-=b[i];
				}
				else
				{
				a[i+1]=0;
				}
			} b[i] -= a[i] b[i] b i a[i] a i if(a[i+1]>=b[i])
				{
				a[i+1]-=b[i];
				}
				else
				{
				a[i+1]=0;
				} a[i+1]>=b[i] a[i+1] a i+1 i 1 b[i] b i {
				a[i+1]-=b[i];
				} a[i+1]-=b[i] a[i+1] a i+1 i 1 b[i] b i {
				a[i+1]=0;
				} a[i+1]=0 a[i+1] a i+1 i 1 0 System.out.println(c) System.out.println System.out System System.out c String args[] args public class Main
{
	public static void main(String args[])
	{
		Scanner x=new Scanner(System.in);
    	int n=x.nextInt();
		long c=0;
    	long a[]=new long[n+1];
		long b[]=new long[n];
		for(int i=0;i<n+1;i++)
		{
			a[i]=x.nextLong();
		}
		for(int i=0;i<n;i++)
		{
			b[i]=x.nextLong();
		}
		for(int i=0;i<n;i++)
		{
			c+=Math.min((a[i]+a[i+1]),b[i]);
			if(a[i]<b[i])
			{	
				b[i] -= a[i];
				if(a[i+1]>=b[i])
				{
				a[i+1]-=b[i];
				}
				else
				{
				a[i+1]=0;
				}
			}
		}
		System.out.println(c);
	}
} public class Main
{
	public static void main(String args[])
	{
		Scanner x=new Scanner(System.in);
    	int n=x.nextInt();
		long c=0;
    	long a[]=new long[n+1];
		long b[]=new long[n];
		for(int i=0;i<n+1;i++)
		{
			a[i]=x.nextLong();
		}
		for(int i=0;i<n;i++)
		{
			b[i]=x.nextLong();
		}
		for(int i=0;i<n;i++)
		{
			c+=Math.min((a[i]+a[i+1]),b[i]);
			if(a[i]<b[i])
			{	
				b[i] -= a[i];
				if(a[i+1]>=b[i])
				{
				a[i+1]-=b[i];
				}
				else
				{
				a[i+1]=0;
				}
			}
		}
		System.out.println(c);
	}
} Main
import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String args[])
	{
		Scanner x=new Scanner(System.in);
    	int n=x.nextInt();
		long c=0;
    	long a[]=new long[n+1];
		long b[]=new long[n];
		for(int i=0;i<n+1;i++)
		{
			a[i]=x.nextLong();
		}
		for(int i=0;i<n;i++)
		{
			b[i]=x.nextLong();
		}
		for(int i=0;i<n;i++)
		{
			c+=Math.min((a[i]+a[i+1]),b[i]);
			if(a[i]<b[i])
			{	
				b[i] -= a[i];
				if(a[i+1]>=b[i])
				{
				a[i+1]-=b[i];
				}
				else
				{
				a[i+1]=0;
				}
			}
		}
		System.out.println(c);
	}
}