
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int nn = sc.nextInt();
		
		long a[] = new long [nn+1];
		long b[] = new long [nn];
		
		long c[] = new long[nn];
		for (int i = 0 ; i < nn+1 ; i ++) {
			
			a[i] = sc.nextInt();
			
		}
		
		for (int i = 0 ; i < nn ; i ++) {
			
			b[i] = sc.nextInt();
		}
		long total = 0;
		for (int n = nn ; n >0 ; n -- ) {
			if (a[n] >= b[n-1]) {
				
				c[n-1] = b[n-1];
				b[n-1] = 0;
			}else {
				c[n-1] = a[n];
				b[n-1] = b[n-1] - a[n];
				if (a[n-1]  >= b[n-1]) {
					c[n-1] += b[n-1];
					a[n-1] = a[n-1] - b[n-1];
				}else {
					
					c[n-1] += a[n-1];
					a[n-1] = 0;
				}
				
			}
			
			total += c[n-1];
		
			
		}
		
		System.out.println(total);
		
	}
} import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int nn = sc.nextInt();
		
		long a[] = new long [nn+1];
		long b[] = new long [nn];
		
		long c[] = new long[nn];
		for (int i = 0 ; i < nn+1 ; i ++) {
			
			a[i] = sc.nextInt();
			
		}
		
		for (int i = 0 ; i < nn ; i ++) {
			
			b[i] = sc.nextInt();
		}
		long total = 0;
		for (int n = nn ; n >0 ; n -- ) {
			if (a[n] >= b[n-1]) {
				
				c[n-1] = b[n-1];
				b[n-1] = 0;
			}else {
				c[n-1] = a[n];
				b[n-1] = b[n-1] - a[n];
				if (a[n-1]  >= b[n-1]) {
					c[n-1] += b[n-1];
					a[n-1] = a[n-1] - b[n-1];
				}else {
					
					c[n-1] += a[n-1];
					a[n-1] = 0;
				}
				
			}
			
			total += c[n-1];
		
			
		}
		
		System.out.println(total);
		
	}
} Main public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int nn = sc.nextInt();
		
		long a[] = new long [nn+1];
		long b[] = new long [nn];
		
		long c[] = new long[nn];
		for (int i = 0 ; i < nn+1 ; i ++) {
			
			a[i] = sc.nextInt();
			
		}
		
		for (int i = 0 ; i < nn ; i ++) {
			
			b[i] = sc.nextInt();
		}
		long total = 0;
		for (int n = nn ; n >0 ; n -- ) {
			if (a[n] >= b[n-1]) {
				
				c[n-1] = b[n-1];
				b[n-1] = 0;
			}else {
				c[n-1] = a[n];
				b[n-1] = b[n-1] - a[n];
				if (a[n-1]  >= b[n-1]) {
					c[n-1] += b[n-1];
					a[n-1] = a[n-1] - b[n-1];
				}else {
					
					c[n-1] += a[n-1];
					a[n-1] = 0;
				}
				
			}
			
			total += c[n-1];
		
			
		}
		
		System.out.println(total);
		
	} main {
		
		Scanner sc = new Scanner(System.in);
		int nn = sc.nextInt();
		
		long a[] = new long [nn+1];
		long b[] = new long [nn];
		
		long c[] = new long[nn];
		for (int i = 0 ; i < nn+1 ; i ++) {
			
			a[i] = sc.nextInt();
			
		}
		
		for (int i = 0 ; i < nn ; i ++) {
			
			b[i] = sc.nextInt();
		}
		long total = 0;
		for (int n = nn ; n >0 ; n -- ) {
			if (a[n] >= b[n-1]) {
				
				c[n-1] = b[n-1];
				b[n-1] = 0;
			}else {
				c[n-1] = a[n];
				b[n-1] = b[n-1] - a[n];
				if (a[n-1]  >= b[n-1]) {
					c[n-1] += b[n-1];
					a[n-1] = a[n-1] - b[n-1];
				}else {
					
					c[n-1] += a[n-1];
					a[n-1] = 0;
				}
				
			}
			
			total += c[n-1];
		
			
		}
		
		System.out.println(total);
		
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int nn = sc.nextInt(); nn sc.nextInt() sc.nextInt sc long a[] = new long [nn+1]; a new long [nn+1] nn+1 nn 1 long b[] = new long [nn]; b new long [nn] nn long c[] = new long[nn]; c new long[nn] nn for (int i = 0 ; i < nn+1 ; i ++) {
			
			a[i] = sc.nextInt();
			
		} int i = 0 ; int i = 0 ; i 0 i < nn+1 i nn+1 nn 1 i ++ i ++ i {
			
			a[i] = sc.nextInt();
			
		} {
			
			a[i] = sc.nextInt();
			
		} a[i] = sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc for (int i = 0 ; i < nn ; i ++) {
			
			b[i] = sc.nextInt();
		} int i = 0 ; int i = 0 ; i 0 i < nn i nn i ++ i ++ i {
			
			b[i] = sc.nextInt();
		} {
			
			b[i] = sc.nextInt();
		} b[i] = sc.nextInt() b[i] b i sc.nextInt() sc.nextInt sc long total = 0; total 0 for (int n = nn ; n >0 ; n -- ) {
			if (a[n] >= b[n-1]) {
				
				c[n-1] = b[n-1];
				b[n-1] = 0;
			}else {
				c[n-1] = a[n];
				b[n-1] = b[n-1] - a[n];
				if (a[n-1]  >= b[n-1]) {
					c[n-1] += b[n-1];
					a[n-1] = a[n-1] - b[n-1];
				}else {
					
					c[n-1] += a[n-1];
					a[n-1] = 0;
				}
				
			}
			
			total += c[n-1];
		
			
		} int n = nn ; int n = nn ; n nn n >0 n 0 n -- n -- n {
			if (a[n] >= b[n-1]) {
				
				c[n-1] = b[n-1];
				b[n-1] = 0;
			}else {
				c[n-1] = a[n];
				b[n-1] = b[n-1] - a[n];
				if (a[n-1]  >= b[n-1]) {
					c[n-1] += b[n-1];
					a[n-1] = a[n-1] - b[n-1];
				}else {
					
					c[n-1] += a[n-1];
					a[n-1] = 0;
				}
				
			}
			
			total += c[n-1];
		
			
		} {
			if (a[n] >= b[n-1]) {
				
				c[n-1] = b[n-1];
				b[n-1] = 0;
			}else {
				c[n-1] = a[n];
				b[n-1] = b[n-1] - a[n];
				if (a[n-1]  >= b[n-1]) {
					c[n-1] += b[n-1];
					a[n-1] = a[n-1] - b[n-1];
				}else {
					
					c[n-1] += a[n-1];
					a[n-1] = 0;
				}
				
			}
			
			total += c[n-1];
		
			
		} if (a[n] >= b[n-1]) {
				
				c[n-1] = b[n-1];
				b[n-1] = 0;
			}else {
				c[n-1] = a[n];
				b[n-1] = b[n-1] - a[n];
				if (a[n-1]  >= b[n-1]) {
					c[n-1] += b[n-1];
					a[n-1] = a[n-1] - b[n-1];
				}else {
					
					c[n-1] += a[n-1];
					a[n-1] = 0;
				}
				
			} a[n] >= b[n-1] a[n] a n b[n-1] b n-1 n 1 {
				
				c[n-1] = b[n-1];
				b[n-1] = 0;
			} c[n-1] = b[n-1] c[n-1] c n-1 n 1 b[n-1] b n-1 n 1 b[n-1] = 0 b[n-1] b n-1 n 1 0 {
				c[n-1] = a[n];
				b[n-1] = b[n-1] - a[n];
				if (a[n-1]  >= b[n-1]) {
					c[n-1] += b[n-1];
					a[n-1] = a[n-1] - b[n-1];
				}else {
					
					c[n-1] += a[n-1];
					a[n-1] = 0;
				}
				
			} c[n-1] = a[n] c[n-1] c n-1 n 1 a[n] a n b[n-1] = b[n-1] - a[n] b[n-1] b n-1 n 1 b[n-1] - a[n] b[n-1] b n-1 n 1 a[n] a n if (a[n-1]  >= b[n-1]) {
					c[n-1] += b[n-1];
					a[n-1] = a[n-1] - b[n-1];
				}else {
					
					c[n-1] += a[n-1];
					a[n-1] = 0;
				} a[n-1]  >= b[n-1] a[n-1] a n-1 n 1 b[n-1] b n-1 n 1 {
					c[n-1] += b[n-1];
					a[n-1] = a[n-1] - b[n-1];
				} c[n-1] += b[n-1] c[n-1] c n-1 n 1 b[n-1] b n-1 n 1 a[n-1] = a[n-1] - b[n-1] a[n-1] a n-1 n 1 a[n-1] - b[n-1] a[n-1] a n-1 n 1 b[n-1] b n-1 n 1 {
					
					c[n-1] += a[n-1];
					a[n-1] = 0;
				} c[n-1] += a[n-1] c[n-1] c n-1 n 1 a[n-1] a n-1 n 1 a[n-1] = 0 a[n-1] a n-1 n 1 0 total += c[n-1] total c[n-1] c n-1 n 1 System.out.println(total) System.out.println System.out System System.out total String[] args args public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int nn = sc.nextInt();
		
		long a[] = new long [nn+1];
		long b[] = new long [nn];
		
		long c[] = new long[nn];
		for (int i = 0 ; i < nn+1 ; i ++) {
			
			a[i] = sc.nextInt();
			
		}
		
		for (int i = 0 ; i < nn ; i ++) {
			
			b[i] = sc.nextInt();
		}
		long total = 0;
		for (int n = nn ; n >0 ; n -- ) {
			if (a[n] >= b[n-1]) {
				
				c[n-1] = b[n-1];
				b[n-1] = 0;
			}else {
				c[n-1] = a[n];
				b[n-1] = b[n-1] - a[n];
				if (a[n-1]  >= b[n-1]) {
					c[n-1] += b[n-1];
					a[n-1] = a[n-1] - b[n-1];
				}else {
					
					c[n-1] += a[n-1];
					a[n-1] = 0;
				}
				
			}
			
			total += c[n-1];
		
			
		}
		
		System.out.println(total);
		
	}
} public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int nn = sc.nextInt();
		
		long a[] = new long [nn+1];
		long b[] = new long [nn];
		
		long c[] = new long[nn];
		for (int i = 0 ; i < nn+1 ; i ++) {
			
			a[i] = sc.nextInt();
			
		}
		
		for (int i = 0 ; i < nn ; i ++) {
			
			b[i] = sc.nextInt();
		}
		long total = 0;
		for (int n = nn ; n >0 ; n -- ) {
			if (a[n] >= b[n-1]) {
				
				c[n-1] = b[n-1];
				b[n-1] = 0;
			}else {
				c[n-1] = a[n];
				b[n-1] = b[n-1] - a[n];
				if (a[n-1]  >= b[n-1]) {
					c[n-1] += b[n-1];
					a[n-1] = a[n-1] - b[n-1];
				}else {
					
					c[n-1] += a[n-1];
					a[n-1] = 0;
				}
				
			}
			
			total += c[n-1];
		
			
		}
		
		System.out.println(total);
		
	}
} Main

import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int nn = sc.nextInt();
		
		long a[] = new long [nn+1];
		long b[] = new long [nn];
		
		long c[] = new long[nn];
		for (int i = 0 ; i < nn+1 ; i ++) {
			
			a[i] = sc.nextInt();
			
		}
		
		for (int i = 0 ; i < nn ; i ++) {
			
			b[i] = sc.nextInt();
		}
		long total = 0;
		for (int n = nn ; n >0 ; n -- ) {
			if (a[n] >= b[n-1]) {
				
				c[n-1] = b[n-1];
				b[n-1] = 0;
			}else {
				c[n-1] = a[n];
				b[n-1] = b[n-1] - a[n];
				if (a[n-1]  >= b[n-1]) {
					c[n-1] += b[n-1];
					a[n-1] = a[n-1] - b[n-1];
				}else {
					
					c[n-1] += a[n-1];
					a[n-1] = 0;
				}
				
			}
			
			total += c[n-1];
		
			
		}
		
		System.out.println(total);
		
	}
}
