import java.util.*;

public class Main {
	private static final String TEST = "";
	Scanner sc;
	int N;
	int[] A;
	int[] B;
	
/*-------------
 * constructor
 */
	public Main() {
		sc = new Scanner(System.in);
	}
	public Main(String input) {
		sc = new Scanner(input);
	}
	
/*------------------
 * instance methods
 */
	void out(Object o) {
		System.out.println(o);
		System.out.flush();
	}
	
	public void exec() throws Exception {
		// 読み込み
		N = sc.nextInt();
		A = new int[N+1];
		B = new int[N+1];
		for (int i = 0; i < N+1; i++) {
			A[i] = sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}
		
		// 処理 A[i] は上書きする
		int remainPower = 0;
		
		long destroyCnt = 0;
		for (int i = 0; i < N+1; i++) {
			// まず remainPower でやっつける
			if (A[i] < remainPower) remainPower = A[i];
			A[i] -= remainPower;
			destroyCnt += remainPower;
			// その上で勇者が戦う
			if (A[i] > B[i]) {
				// 魔物が多い。倒して力尽きる
				destroyCnt += B[i];
				remainPower = 0;
			} else {
				// 力があまる
				destroyCnt += A[i];
				remainPower = B[i] - A[i];
			}
		}
		out(destroyCnt);
	}
	
/*------
 * main
 */
	public static void main(String[] args) throws Exception {
		Main m = new Main();
		m.exec();
	}
}

	 import java.util.*; util.* java public class Main {
	private static final String TEST = "";
	Scanner sc;
	int N;
	int[] A;
	int[] B;
	
/*-------------
 * constructor
 */
	public Main() {
		sc = new Scanner(System.in);
	}
	public Main(String input) {
		sc = new Scanner(input);
	}
	
/*------------------
 * instance methods
 */
	void out(Object o) {
		System.out.println(o);
		System.out.flush();
	}
	
	public void exec() throws Exception {
		// 読み込み
		N = sc.nextInt();
		A = new int[N+1];
		B = new int[N+1];
		for (int i = 0; i < N+1; i++) {
			A[i] = sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}
		
		// 処理 A[i] は上書きする
		int remainPower = 0;
		
		long destroyCnt = 0;
		for (int i = 0; i < N+1; i++) {
			// まず remainPower でやっつける
			if (A[i] < remainPower) remainPower = A[i];
			A[i] -= remainPower;
			destroyCnt += remainPower;
			// その上で勇者が戦う
			if (A[i] > B[i]) {
				// 魔物が多い。倒して力尽きる
				destroyCnt += B[i];
				remainPower = 0;
			} else {
				// 力があまる
				destroyCnt += A[i];
				remainPower = B[i] - A[i];
			}
		}
		out(destroyCnt);
	}
	
/*------
 * main
 */
	public static void main(String[] args) throws Exception {
		Main m = new Main();
		m.exec();
	}
} Main private static final String TEST = ""; TEST "" Scanner sc; sc int N; N int[] A; A int[] B; B /*-------------
 * constructor
 */
	public Main() {
		sc = new Scanner(System.in);
	} Main {
		sc = new Scanner(System.in);
	} sc = new Scanner(System.in) sc new Scanner(System.in) public Main(String input) {
		sc = new Scanner(input);
	} Main {
		sc = new Scanner(input);
	} sc = new Scanner(input) sc new Scanner(input) String input input /*------------------
 * instance methods
 */
	void out(Object o) {
		System.out.println(o);
		System.out.flush();
	} out {
		System.out.println(o);
		System.out.flush();
	} System.out.println(o) System.out.println System.out System System.out o System.out.flush() System.out.flush System.out System System.out Object o o public void exec() throws Exception {
		// 読み込み
		N = sc.nextInt();
		A = new int[N+1];
		B = new int[N+1];
		for (int i = 0; i < N+1; i++) {
			A[i] = sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}
		
		// 処理 A[i] は上書きする
		int remainPower = 0;
		
		long destroyCnt = 0;
		for (int i = 0; i < N+1; i++) {
			// まず remainPower でやっつける
			if (A[i] < remainPower) remainPower = A[i];
			A[i] -= remainPower;
			destroyCnt += remainPower;
			// その上で勇者が戦う
			if (A[i] > B[i]) {
				// 魔物が多い。倒して力尽きる
				destroyCnt += B[i];
				remainPower = 0;
			} else {
				// 力があまる
				destroyCnt += A[i];
				remainPower = B[i] - A[i];
			}
		}
		out(destroyCnt);
	} exec {
		// 読み込み
		N = sc.nextInt();
		A = new int[N+1];
		B = new int[N+1];
		for (int i = 0; i < N+1; i++) {
			A[i] = sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}
		
		// 処理 A[i] は上書きする
		int remainPower = 0;
		
		long destroyCnt = 0;
		for (int i = 0; i < N+1; i++) {
			// まず remainPower でやっつける
			if (A[i] < remainPower) remainPower = A[i];
			A[i] -= remainPower;
			destroyCnt += remainPower;
			// その上で勇者が戦う
			if (A[i] > B[i]) {
				// 魔物が多い。倒して力尽きる
				destroyCnt += B[i];
				remainPower = 0;
			} else {
				// 力があまる
				destroyCnt += A[i];
				remainPower = B[i] - A[i];
			}
		}
		out(destroyCnt);
	} N = sc.nextInt() N sc.nextInt() sc.nextInt sc A = new int[N+1] A new int[N+1] N+1 N 1 B = new int[N+1] B 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 for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			B[i] = sc.nextInt();
		} {
			B[i] = sc.nextInt();
		} B[i] = sc.nextInt() B[i] B i sc.nextInt() sc.nextInt sc int remainPower = 0; remainPower 0 long destroyCnt = 0; destroyCnt 0 for (int i = 0; i < N+1; i++) {
			// まず remainPower でやっつける
			if (A[i] < remainPower) remainPower = A[i];
			A[i] -= remainPower;
			destroyCnt += remainPower;
			// その上で勇者が戦う
			if (A[i] > B[i]) {
				// 魔物が多い。倒して力尽きる
				destroyCnt += B[i];
				remainPower = 0;
			} else {
				// 力があまる
				destroyCnt += A[i];
				remainPower = B[i] - A[i];
			}
		} int i = 0; int i = 0; i 0 i < N+1 i N+1 N 1 i++ i++ i {
			// まず remainPower でやっつける
			if (A[i] < remainPower) remainPower = A[i];
			A[i] -= remainPower;
			destroyCnt += remainPower;
			// その上で勇者が戦う
			if (A[i] > B[i]) {
				// 魔物が多い。倒して力尽きる
				destroyCnt += B[i];
				remainPower = 0;
			} else {
				// 力があまる
				destroyCnt += A[i];
				remainPower = B[i] - A[i];
			}
		} {
			// まず remainPower でやっつける
			if (A[i] < remainPower) remainPower = A[i];
			A[i] -= remainPower;
			destroyCnt += remainPower;
			// その上で勇者が戦う
			if (A[i] > B[i]) {
				// 魔物が多い。倒して力尽きる
				destroyCnt += B[i];
				remainPower = 0;
			} else {
				// 力があまる
				destroyCnt += A[i];
				remainPower = B[i] - A[i];
			}
		} if (A[i] < remainPower) remainPower = A[i]; A[i] < remainPower A[i] A i remainPower remainPower = A[i] remainPower A[i] A i A[i] -= remainPower A[i] A i remainPower destroyCnt += remainPower destroyCnt remainPower if (A[i] > B[i]) {
				// 魔物が多い。倒して力尽きる
				destroyCnt += B[i];
				remainPower = 0;
			} else {
				// 力があまる
				destroyCnt += A[i];
				remainPower = B[i] - A[i];
			} A[i] > B[i] A[i] A i B[i] B i {
				// 魔物が多い。倒して力尽きる
				destroyCnt += B[i];
				remainPower = 0;
			} destroyCnt += B[i] destroyCnt B[i] B i remainPower = 0 remainPower 0 {
				// 力があまる
				destroyCnt += A[i];
				remainPower = B[i] - A[i];
			} destroyCnt += A[i] destroyCnt A[i] A i remainPower = B[i] - A[i] remainPower B[i] - A[i] B[i] B i A[i] A i out(destroyCnt) out destroyCnt /*------
 * main
 */
	public static void main(String[] args) throws Exception {
		Main m = new Main();
		m.exec();
	} main {
		Main m = new Main();
		m.exec();
	} Main m = new Main(); m new Main() m.exec() m.exec m String[] args args public class Main {
	private static final String TEST = "";
	Scanner sc;
	int N;
	int[] A;
	int[] B;
	
/*-------------
 * constructor
 */
	public Main() {
		sc = new Scanner(System.in);
	}
	public Main(String input) {
		sc = new Scanner(input);
	}
	
/*------------------
 * instance methods
 */
	void out(Object o) {
		System.out.println(o);
		System.out.flush();
	}
	
	public void exec() throws Exception {
		// 読み込み
		N = sc.nextInt();
		A = new int[N+1];
		B = new int[N+1];
		for (int i = 0; i < N+1; i++) {
			A[i] = sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}
		
		// 処理 A[i] は上書きする
		int remainPower = 0;
		
		long destroyCnt = 0;
		for (int i = 0; i < N+1; i++) {
			// まず remainPower でやっつける
			if (A[i] < remainPower) remainPower = A[i];
			A[i] -= remainPower;
			destroyCnt += remainPower;
			// その上で勇者が戦う
			if (A[i] > B[i]) {
				// 魔物が多い。倒して力尽きる
				destroyCnt += B[i];
				remainPower = 0;
			} else {
				// 力があまる
				destroyCnt += A[i];
				remainPower = B[i] - A[i];
			}
		}
		out(destroyCnt);
	}
	
/*------
 * main
 */
	public static void main(String[] args) throws Exception {
		Main m = new Main();
		m.exec();
	}
} public class Main {
	private static final String TEST = "";
	Scanner sc;
	int N;
	int[] A;
	int[] B;
	
/*-------------
 * constructor
 */
	public Main() {
		sc = new Scanner(System.in);
	}
	public Main(String input) {
		sc = new Scanner(input);
	}
	
/*------------------
 * instance methods
 */
	void out(Object o) {
		System.out.println(o);
		System.out.flush();
	}
	
	public void exec() throws Exception {
		// 読み込み
		N = sc.nextInt();
		A = new int[N+1];
		B = new int[N+1];
		for (int i = 0; i < N+1; i++) {
			A[i] = sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}
		
		// 処理 A[i] は上書きする
		int remainPower = 0;
		
		long destroyCnt = 0;
		for (int i = 0; i < N+1; i++) {
			// まず remainPower でやっつける
			if (A[i] < remainPower) remainPower = A[i];
			A[i] -= remainPower;
			destroyCnt += remainPower;
			// その上で勇者が戦う
			if (A[i] > B[i]) {
				// 魔物が多い。倒して力尽きる
				destroyCnt += B[i];
				remainPower = 0;
			} else {
				// 力があまる
				destroyCnt += A[i];
				remainPower = B[i] - A[i];
			}
		}
		out(destroyCnt);
	}
	
/*------
 * main
 */
	public static void main(String[] args) throws Exception {
		Main m = new Main();
		m.exec();
	}
} Main
import java.util.*;

public class Main {
	private static final String TEST = "";
	Scanner sc;
	int N;
	int[] A;
	int[] B;
	
/*-------------
 * constructor
 */
	public Main() {
		sc = new Scanner(System.in);
	}
	public Main(String input) {
		sc = new Scanner(input);
	}
	
/*------------------
 * instance methods
 */
	void out(Object o) {
		System.out.println(o);
		System.out.flush();
	}
	
	public void exec() throws Exception {
		// 読み込み
		N = sc.nextInt();
		A = new int[N+1];
		B = new int[N+1];
		for (int i = 0; i < N+1; i++) {
			A[i] = sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}
		
		// 処理 A[i] は上書きする
		int remainPower = 0;
		
		long destroyCnt = 0;
		for (int i = 0; i < N+1; i++) {
			// まず remainPower でやっつける
			if (A[i] < remainPower) remainPower = A[i];
			A[i] -= remainPower;
			destroyCnt += remainPower;
			// その上で勇者が戦う
			if (A[i] > B[i]) {
				// 魔物が多い。倒して力尽きる
				destroyCnt += B[i];
				remainPower = 0;
			} else {
				// 力があまる
				destroyCnt += A[i];
				remainPower = B[i] - A[i];
			}
		}
		out(destroyCnt);
	}
	
/*------
 * main
 */
	public static void main(String[] args) throws Exception {
		Main m = new Main();
		m.exec();
	}
}

	