import java.util.*;

public class Main {
	
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n=Integer.parseInt(scan.next());
		int[] a =new int [n+1];
		int[] b =new int [n];
		for(int i=0;i<n+1;++i) {
			a[i]=Integer.parseInt(scan.next());
		}
		for(int i=0;i<n;++i) {
			b[i]=Integer.parseInt(scan.next());
		}
		
		long ans=0;
		int old=0;
		for (int i=0;i<n;++i) {
			ans+=Math.min(a[i], b[i]);
			ans+=Math.min(a[i+1],b[i]-Math.min(a[i], b[i]));
			a[i+1]-=Math.min(a[i+1],b[i]-Math.min(a[i], b[i]));
			
			//System.out.println(ans);
		}
		//ans+=Math.min(a[n], old);
		

		System.out.print(ans);
		
}
}
//end import java.util.*; util.* java public class Main {
	
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n=Integer.parseInt(scan.next());
		int[] a =new int [n+1];
		int[] b =new int [n];
		for(int i=0;i<n+1;++i) {
			a[i]=Integer.parseInt(scan.next());
		}
		for(int i=0;i<n;++i) {
			b[i]=Integer.parseInt(scan.next());
		}
		
		long ans=0;
		int old=0;
		for (int i=0;i<n;++i) {
			ans+=Math.min(a[i], b[i]);
			ans+=Math.min(a[i+1],b[i]-Math.min(a[i], b[i]));
			a[i+1]-=Math.min(a[i+1],b[i]-Math.min(a[i], b[i]));
			
			//System.out.println(ans);
		}
		//ans+=Math.min(a[n], old);
		

		System.out.print(ans);
		
}
} Main public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n=Integer.parseInt(scan.next());
		int[] a =new int [n+1];
		int[] b =new int [n];
		for(int i=0;i<n+1;++i) {
			a[i]=Integer.parseInt(scan.next());
		}
		for(int i=0;i<n;++i) {
			b[i]=Integer.parseInt(scan.next());
		}
		
		long ans=0;
		int old=0;
		for (int i=0;i<n;++i) {
			ans+=Math.min(a[i], b[i]);
			ans+=Math.min(a[i+1],b[i]-Math.min(a[i], b[i]));
			a[i+1]-=Math.min(a[i+1],b[i]-Math.min(a[i], b[i]));
			
			//System.out.println(ans);
		}
		//ans+=Math.min(a[n], old);
		

		System.out.print(ans);
		
} main {
		Scanner scan = new Scanner(System.in);
		int n=Integer.parseInt(scan.next());
		int[] a =new int [n+1];
		int[] b =new int [n];
		for(int i=0;i<n+1;++i) {
			a[i]=Integer.parseInt(scan.next());
		}
		for(int i=0;i<n;++i) {
			b[i]=Integer.parseInt(scan.next());
		}
		
		long ans=0;
		int old=0;
		for (int i=0;i<n;++i) {
			ans+=Math.min(a[i], b[i]);
			ans+=Math.min(a[i+1],b[i]-Math.min(a[i], b[i]));
			a[i+1]-=Math.min(a[i+1],b[i]-Math.min(a[i], b[i]));
			
			//System.out.println(ans);
		}
		//ans+=Math.min(a[n], old);
		

		System.out.print(ans);
		
} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n=Integer.parseInt(scan.next()); n Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan int[] a =new int [n+1]; a new int [n+1] n+1 n 1 int[] b =new int [n]; b new int [n] n for(int i=0;i<n+1;++i) {
			a[i]=Integer.parseInt(scan.next());
		} int i=0; int i=0; i 0 i<n+1 i n+1 n 1 ++i ++i i {
			a[i]=Integer.parseInt(scan.next());
		} {
			a[i]=Integer.parseInt(scan.next());
		} a[i]=Integer.parseInt(scan.next()) a[i] a i Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan for(int i=0;i<n;++i) {
			b[i]=Integer.parseInt(scan.next());
		} int i=0; int i=0; i 0 i<n i n ++i ++i i {
			b[i]=Integer.parseInt(scan.next());
		} {
			b[i]=Integer.parseInt(scan.next());
		} b[i]=Integer.parseInt(scan.next()) b[i] b i Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan long ans=0; ans 0 int old=0; old 0 for (int i=0;i<n;++i) {
			ans+=Math.min(a[i], b[i]);
			ans+=Math.min(a[i+1],b[i]-Math.min(a[i], b[i]));
			a[i+1]-=Math.min(a[i+1],b[i]-Math.min(a[i], b[i]));
			
			//System.out.println(ans);
		} int i=0; int i=0; i 0 i<n i n ++i ++i i {
			ans+=Math.min(a[i], b[i]);
			ans+=Math.min(a[i+1],b[i]-Math.min(a[i], b[i]));
			a[i+1]-=Math.min(a[i+1],b[i]-Math.min(a[i], b[i]));
			
			//System.out.println(ans);
		} {
			ans+=Math.min(a[i], b[i]);
			ans+=Math.min(a[i+1],b[i]-Math.min(a[i], b[i]));
			a[i+1]-=Math.min(a[i+1],b[i]-Math.min(a[i], b[i]));
			
			//System.out.println(ans);
		} ans+=Math.min(a[i], b[i]) ans Math.min(a[i], b[i]) Math.min Math a[i] a i b[i] b i ans+=Math.min(a[i+1],b[i]-Math.min(a[i], b[i])) ans Math.min(a[i+1],b[i]-Math.min(a[i], b[i])) Math.min Math a[i+1] a i+1 i 1 b[i]-Math.min(a[i], b[i]) b[i] b i Math.min(a[i], b[i]) Math.min Math a[i] a i b[i] b i a[i+1]-=Math.min(a[i+1],b[i]-Math.min(a[i], b[i])) a[i+1] a i+1 i 1 Math.min(a[i+1],b[i]-Math.min(a[i], b[i])) Math.min Math a[i+1] a i+1 i 1 b[i]-Math.min(a[i], b[i]) b[i] b i Math.min(a[i], b[i]) Math.min Math a[i] a i b[i] b i System.out.print(ans) System.out.print 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=Integer.parseInt(scan.next());
		int[] a =new int [n+1];
		int[] b =new int [n];
		for(int i=0;i<n+1;++i) {
			a[i]=Integer.parseInt(scan.next());
		}
		for(int i=0;i<n;++i) {
			b[i]=Integer.parseInt(scan.next());
		}
		
		long ans=0;
		int old=0;
		for (int i=0;i<n;++i) {
			ans+=Math.min(a[i], b[i]);
			ans+=Math.min(a[i+1],b[i]-Math.min(a[i], b[i]));
			a[i+1]-=Math.min(a[i+1],b[i]-Math.min(a[i], b[i]));
			
			//System.out.println(ans);
		}
		//ans+=Math.min(a[n], old);
		

		System.out.print(ans);
		
}
} public class Main {
	
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n=Integer.parseInt(scan.next());
		int[] a =new int [n+1];
		int[] b =new int [n];
		for(int i=0;i<n+1;++i) {
			a[i]=Integer.parseInt(scan.next());
		}
		for(int i=0;i<n;++i) {
			b[i]=Integer.parseInt(scan.next());
		}
		
		long ans=0;
		int old=0;
		for (int i=0;i<n;++i) {
			ans+=Math.min(a[i], b[i]);
			ans+=Math.min(a[i+1],b[i]-Math.min(a[i], b[i]));
			a[i+1]-=Math.min(a[i+1],b[i]-Math.min(a[i], b[i]));
			
			//System.out.println(ans);
		}
		//ans+=Math.min(a[n], old);
		

		System.out.print(ans);
		
}
} Main
import java.util.*;

public class Main {
	
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n=Integer.parseInt(scan.next());
		int[] a =new int [n+1];
		int[] b =new int [n];
		for(int i=0;i<n+1;++i) {
			a[i]=Integer.parseInt(scan.next());
		}
		for(int i=0;i<n;++i) {
			b[i]=Integer.parseInt(scan.next());
		}
		
		long ans=0;
		int old=0;
		for (int i=0;i<n;++i) {
			ans+=Math.min(a[i], b[i]);
			ans+=Math.min(a[i+1],b[i]-Math.min(a[i], b[i]));
			a[i+1]-=Math.min(a[i+1],b[i]-Math.min(a[i], b[i]));
			
			//System.out.println(ans);
		}
		//ans+=Math.min(a[n], old);
		

		System.out.print(ans);
		
}
}
//end