import java.util.*;
import static java.lang.System.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(in);
		int N = sc.nextInt();
		int[] A = new int[N+1];
		for(int i=0;i<N+1;i++) {
			A[i] = sc.nextInt();
		}
		
		long ret = 0;
		for(int i=0;i<N;i++) {
			int b = sc.nextInt();
			if(A[i]-b>=0) {
				ret += b;
				continue;
			}
			else {
				ret += A[i];
				b = b - A[i];
				ret += Math.min(A[i+1], b);
				A[i+1] -= Math.min(A[i+1], b);
			}
		}
		
		out.println(ret);
		sc.close();
	}
} import java.util.*; util.* java import static java.lang.System.*; import static java.lang.System.*; import static java.lang.System.*; public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(in);
		int N = sc.nextInt();
		int[] A = new int[N+1];
		for(int i=0;i<N+1;i++) {
			A[i] = sc.nextInt();
		}
		
		long ret = 0;
		for(int i=0;i<N;i++) {
			int b = sc.nextInt();
			if(A[i]-b>=0) {
				ret += b;
				continue;
			}
			else {
				ret += A[i];
				b = b - A[i];
				ret += Math.min(A[i+1], b);
				A[i+1] -= Math.min(A[i+1], b);
			}
		}
		
		out.println(ret);
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(in);
		int N = sc.nextInt();
		int[] A = new int[N+1];
		for(int i=0;i<N+1;i++) {
			A[i] = sc.nextInt();
		}
		
		long ret = 0;
		for(int i=0;i<N;i++) {
			int b = sc.nextInt();
			if(A[i]-b>=0) {
				ret += b;
				continue;
			}
			else {
				ret += A[i];
				b = b - A[i];
				ret += Math.min(A[i+1], b);
				A[i+1] -= Math.min(A[i+1], b);
			}
		}
		
		out.println(ret);
		sc.close();
	} main {
		Scanner sc = new Scanner(in);
		int N = sc.nextInt();
		int[] A = new int[N+1];
		for(int i=0;i<N+1;i++) {
			A[i] = sc.nextInt();
		}
		
		long ret = 0;
		for(int i=0;i<N;i++) {
			int b = sc.nextInt();
			if(A[i]-b>=0) {
				ret += b;
				continue;
			}
			else {
				ret += A[i];
				b = b - A[i];
				ret += Math.min(A[i+1], b);
				A[i+1] -= Math.min(A[i+1], b);
			}
		}
		
		out.println(ret);
		sc.close();
	} Scanner sc = new Scanner(in); sc new Scanner(in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] A = new int[N+1]; A new int[N+1] N+1 N 1 for(int i=0;i<N+1;i++) {
			A[i] = sc.nextInt();
		} int i=0; int i=0; i 0 i<N+1 i N+1 N 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 long ret = 0; ret 0 for(int i=0;i<N;i++) {
			int b = sc.nextInt();
			if(A[i]-b>=0) {
				ret += b;
				continue;
			}
			else {
				ret += A[i];
				b = b - A[i];
				ret += Math.min(A[i+1], b);
				A[i+1] -= Math.min(A[i+1], b);
			}
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			int b = sc.nextInt();
			if(A[i]-b>=0) {
				ret += b;
				continue;
			}
			else {
				ret += A[i];
				b = b - A[i];
				ret += Math.min(A[i+1], b);
				A[i+1] -= Math.min(A[i+1], b);
			}
		} {
			int b = sc.nextInt();
			if(A[i]-b>=0) {
				ret += b;
				continue;
			}
			else {
				ret += A[i];
				b = b - A[i];
				ret += Math.min(A[i+1], b);
				A[i+1] -= Math.min(A[i+1], b);
			}
		} int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc if(A[i]-b>=0) {
				ret += b;
				continue;
			}
			else {
				ret += A[i];
				b = b - A[i];
				ret += Math.min(A[i+1], b);
				A[i+1] -= Math.min(A[i+1], b);
			} A[i]-b>=0 A[i]-b A[i] A i b 0 {
				ret += b;
				continue;
			} ret += b ret b continue; {
				ret += A[i];
				b = b - A[i];
				ret += Math.min(A[i+1], b);
				A[i+1] -= Math.min(A[i+1], b);
			} ret += A[i] ret A[i] A i b = b - A[i] b b - A[i] b A[i] A i ret += Math.min(A[i+1], b) ret Math.min(A[i+1], b) Math.min Math A[i+1] A i+1 i 1 b A[i+1] -= Math.min(A[i+1], b) A[i+1] A i+1 i 1 Math.min(A[i+1], b) Math.min Math A[i+1] A i+1 i 1 b out.println(ret) out.println out ret sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(in);
		int N = sc.nextInt();
		int[] A = new int[N+1];
		for(int i=0;i<N+1;i++) {
			A[i] = sc.nextInt();
		}
		
		long ret = 0;
		for(int i=0;i<N;i++) {
			int b = sc.nextInt();
			if(A[i]-b>=0) {
				ret += b;
				continue;
			}
			else {
				ret += A[i];
				b = b - A[i];
				ret += Math.min(A[i+1], b);
				A[i+1] -= Math.min(A[i+1], b);
			}
		}
		
		out.println(ret);
		sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(in);
		int N = sc.nextInt();
		int[] A = new int[N+1];
		for(int i=0;i<N+1;i++) {
			A[i] = sc.nextInt();
		}
		
		long ret = 0;
		for(int i=0;i<N;i++) {
			int b = sc.nextInt();
			if(A[i]-b>=0) {
				ret += b;
				continue;
			}
			else {
				ret += A[i];
				b = b - A[i];
				ret += Math.min(A[i+1], b);
				A[i+1] -= Math.min(A[i+1], b);
			}
		}
		
		out.println(ret);
		sc.close();
	}
} Main
import java.util.*;
import static java.lang.System.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(in);
		int N = sc.nextInt();
		int[] A = new int[N+1];
		for(int i=0;i<N+1;i++) {
			A[i] = sc.nextInt();
		}
		
		long ret = 0;
		for(int i=0;i<N;i++) {
			int b = sc.nextInt();
			if(A[i]-b>=0) {
				ret += b;
				continue;
			}
			else {
				ret += A[i];
				b = b - A[i];
				ret += Math.min(A[i+1], b);
				A[i+1] -= Math.min(A[i+1], b);
			}
		}
		
		out.println(ret);
		sc.close();
	}
}