import java.util.*;
public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N  = keyboard.nextInt();
		int[] A = new int[N+1];
		int[] B = new int[N];
		
		for(int i=0; i<N+1; i++) {
			 A[i] = keyboard.nextInt();
		}
		for(int j=0; j<N; j++) {
			 B[j] = keyboard.nextInt();
		}
		
		long count = 0;
		for(int k = N; k>=1; k--) {
			if(A[k] >= B[k-1]) {
				count += B[k-1];
			}else{
				count += A[k];
				if(A[k-1] >= B[k-1]-A[k]) {
					count += B[k-1]-A[k];
					A[k-1] -= B[k-1]-A[k];
				}else{
					count += A[k-1];
					A[k-1] = 0;
				}	
			}
		}
		System.out.println(count);
		keyboard.close();	
	}
} import java.util.*; util.* java public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N  = keyboard.nextInt();
		int[] A = new int[N+1];
		int[] B = new int[N];
		
		for(int i=0; i<N+1; i++) {
			 A[i] = keyboard.nextInt();
		}
		for(int j=0; j<N; j++) {
			 B[j] = keyboard.nextInt();
		}
		
		long count = 0;
		for(int k = N; k>=1; k--) {
			if(A[k] >= B[k-1]) {
				count += B[k-1];
			}else{
				count += A[k];
				if(A[k-1] >= B[k-1]-A[k]) {
					count += B[k-1]-A[k];
					A[k-1] -= B[k-1]-A[k];
				}else{
					count += A[k-1];
					A[k-1] = 0;
				}	
			}
		}
		System.out.println(count);
		keyboard.close();	
	}
} Main public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N  = keyboard.nextInt();
		int[] A = new int[N+1];
		int[] B = new int[N];
		
		for(int i=0; i<N+1; i++) {
			 A[i] = keyboard.nextInt();
		}
		for(int j=0; j<N; j++) {
			 B[j] = keyboard.nextInt();
		}
		
		long count = 0;
		for(int k = N; k>=1; k--) {
			if(A[k] >= B[k-1]) {
				count += B[k-1];
			}else{
				count += A[k];
				if(A[k-1] >= B[k-1]-A[k]) {
					count += B[k-1]-A[k];
					A[k-1] -= B[k-1]-A[k];
				}else{
					count += A[k-1];
					A[k-1] = 0;
				}	
			}
		}
		System.out.println(count);
		keyboard.close();	
	} main {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N  = keyboard.nextInt();
		int[] A = new int[N+1];
		int[] B = new int[N];
		
		for(int i=0; i<N+1; i++) {
			 A[i] = keyboard.nextInt();
		}
		for(int j=0; j<N; j++) {
			 B[j] = keyboard.nextInt();
		}
		
		long count = 0;
		for(int k = N; k>=1; k--) {
			if(A[k] >= B[k-1]) {
				count += B[k-1];
			}else{
				count += A[k];
				if(A[k-1] >= B[k-1]-A[k]) {
					count += B[k-1]-A[k];
					A[k-1] -= B[k-1]-A[k];
				}else{
					count += A[k-1];
					A[k-1] = 0;
				}	
			}
		}
		System.out.println(count);
		keyboard.close();	
	} Scanner keyboard = new Scanner(System.in); keyboard new Scanner(System.in) int N  = keyboard.nextInt(); N keyboard.nextInt() keyboard.nextInt keyboard 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] = keyboard.nextInt();
		} int i=0; int i=0; i 0 i<N+1 i N+1 N 1 i++ i++ i {
			 A[i] = keyboard.nextInt();
		} {
			 A[i] = keyboard.nextInt();
		} A[i] = keyboard.nextInt() A[i] A i keyboard.nextInt() keyboard.nextInt keyboard for(int j=0; j<N; j++) {
			 B[j] = keyboard.nextInt();
		} int j=0; int j=0; j 0 j<N j N j++ j++ j {
			 B[j] = keyboard.nextInt();
		} {
			 B[j] = keyboard.nextInt();
		} B[j] = keyboard.nextInt() B[j] B j keyboard.nextInt() keyboard.nextInt keyboard long count = 0; count 0 for(int k = N; k>=1; k--) {
			if(A[k] >= B[k-1]) {
				count += B[k-1];
			}else{
				count += A[k];
				if(A[k-1] >= B[k-1]-A[k]) {
					count += B[k-1]-A[k];
					A[k-1] -= B[k-1]-A[k];
				}else{
					count += A[k-1];
					A[k-1] = 0;
				}	
			}
		} int k = N; int k = N; k N k>=1 k 1 k-- k-- k {
			if(A[k] >= B[k-1]) {
				count += B[k-1];
			}else{
				count += A[k];
				if(A[k-1] >= B[k-1]-A[k]) {
					count += B[k-1]-A[k];
					A[k-1] -= B[k-1]-A[k];
				}else{
					count += A[k-1];
					A[k-1] = 0;
				}	
			}
		} {
			if(A[k] >= B[k-1]) {
				count += B[k-1];
			}else{
				count += A[k];
				if(A[k-1] >= B[k-1]-A[k]) {
					count += B[k-1]-A[k];
					A[k-1] -= B[k-1]-A[k];
				}else{
					count += A[k-1];
					A[k-1] = 0;
				}	
			}
		} if(A[k] >= B[k-1]) {
				count += B[k-1];
			}else{
				count += A[k];
				if(A[k-1] >= B[k-1]-A[k]) {
					count += B[k-1]-A[k];
					A[k-1] -= B[k-1]-A[k];
				}else{
					count += A[k-1];
					A[k-1] = 0;
				}	
			} A[k] >= B[k-1] A[k] A k B[k-1] B k-1 k 1 {
				count += B[k-1];
			} count += B[k-1] count B[k-1] B k-1 k 1 {
				count += A[k];
				if(A[k-1] >= B[k-1]-A[k]) {
					count += B[k-1]-A[k];
					A[k-1] -= B[k-1]-A[k];
				}else{
					count += A[k-1];
					A[k-1] = 0;
				}	
			} count += A[k] count A[k] A k if(A[k-1] >= B[k-1]-A[k]) {
					count += B[k-1]-A[k];
					A[k-1] -= B[k-1]-A[k];
				}else{
					count += A[k-1];
					A[k-1] = 0;
				} A[k-1] >= B[k-1]-A[k] A[k-1] A k-1 k 1 B[k-1]-A[k] B[k-1] B k-1 k 1 A[k] A k {
					count += B[k-1]-A[k];
					A[k-1] -= B[k-1]-A[k];
				} count += B[k-1]-A[k] count B[k-1]-A[k] B[k-1] B k-1 k 1 A[k] A k A[k-1] -= B[k-1]-A[k] A[k-1] A k-1 k 1 B[k-1]-A[k] B[k-1] B k-1 k 1 A[k] A k {
					count += A[k-1];
					A[k-1] = 0;
				} count += A[k-1] count A[k-1] A k-1 k 1 A[k-1] = 0 A[k-1] A k-1 k 1 0 System.out.println(count) System.out.println System.out System System.out count keyboard.close() keyboard.close keyboard String[] args args public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N  = keyboard.nextInt();
		int[] A = new int[N+1];
		int[] B = new int[N];
		
		for(int i=0; i<N+1; i++) {
			 A[i] = keyboard.nextInt();
		}
		for(int j=0; j<N; j++) {
			 B[j] = keyboard.nextInt();
		}
		
		long count = 0;
		for(int k = N; k>=1; k--) {
			if(A[k] >= B[k-1]) {
				count += B[k-1];
			}else{
				count += A[k];
				if(A[k-1] >= B[k-1]-A[k]) {
					count += B[k-1]-A[k];
					A[k-1] -= B[k-1]-A[k];
				}else{
					count += A[k-1];
					A[k-1] = 0;
				}	
			}
		}
		System.out.println(count);
		keyboard.close();	
	}
} public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N  = keyboard.nextInt();
		int[] A = new int[N+1];
		int[] B = new int[N];
		
		for(int i=0; i<N+1; i++) {
			 A[i] = keyboard.nextInt();
		}
		for(int j=0; j<N; j++) {
			 B[j] = keyboard.nextInt();
		}
		
		long count = 0;
		for(int k = N; k>=1; k--) {
			if(A[k] >= B[k-1]) {
				count += B[k-1];
			}else{
				count += A[k];
				if(A[k-1] >= B[k-1]-A[k]) {
					count += B[k-1]-A[k];
					A[k-1] -= B[k-1]-A[k];
				}else{
					count += A[k-1];
					A[k-1] = 0;
				}	
			}
		}
		System.out.println(count);
		keyboard.close();	
	}
} Main
import java.util.*;
public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N  = keyboard.nextInt();
		int[] A = new int[N+1];
		int[] B = new int[N];
		
		for(int i=0; i<N+1; i++) {
			 A[i] = keyboard.nextInt();
		}
		for(int j=0; j<N; j++) {
			 B[j] = keyboard.nextInt();
		}
		
		long count = 0;
		for(int k = N; k>=1; k--) {
			if(A[k] >= B[k-1]) {
				count += B[k-1];
			}else{
				count += A[k];
				if(A[k-1] >= B[k-1]-A[k]) {
					count += B[k-1]-A[k];
					A[k-1] -= B[k-1]-A[k];
				}else{
					count += A[k-1];
					A[k-1] = 0;
				}	
			}
		}
		System.out.println(count);
		keyboard.close();	
	}
}
