import java.util.*;

public class Main {

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

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] arrA = new long[n + 1];
		for (int i = 0; i <= n; i++) {
			arrA[i] = sc.nextInt();
		}
		long total = 0;
		for (int i = 0; i < n; i++) {
			long b = sc.nextInt();
			if (b > arrA[i]) {
				total += arrA[i];
				b -= arrA[i];
				total += Math.min(arrA[i + 1], b);
				arrA[i + 1] = Math.max(0, arrA[i + 1] - b);
			} else {
				total += b;
			}
		}
		System.out.println(total);
	}
} Main public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] arrA = new long[n + 1];
		for (int i = 0; i <= n; i++) {
			arrA[i] = sc.nextInt();
		}
		long total = 0;
		for (int i = 0; i < n; i++) {
			long b = sc.nextInt();
			if (b > arrA[i]) {
				total += arrA[i];
				b -= arrA[i];
				total += Math.min(arrA[i + 1], b);
				arrA[i + 1] = Math.max(0, arrA[i + 1] - b);
			} else {
				total += b;
			}
		}
		System.out.println(total);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] arrA = new long[n + 1];
		for (int i = 0; i <= n; i++) {
			arrA[i] = sc.nextInt();
		}
		long total = 0;
		for (int i = 0; i < n; i++) {
			long b = sc.nextInt();
			if (b > arrA[i]) {
				total += arrA[i];
				b -= arrA[i];
				total += Math.min(arrA[i + 1], b);
				arrA[i + 1] = Math.max(0, arrA[i + 1] - b);
			} else {
				total += b;
			}
		}
		System.out.println(total);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc long[] arrA = new long[n + 1]; arrA new long[n + 1] n + 1 n 1 for (int i = 0; i <= n; i++) {
			arrA[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i <= n i n i++ i++ i {
			arrA[i] = sc.nextInt();
		} {
			arrA[i] = sc.nextInt();
		} arrA[i] = sc.nextInt() arrA[i] arrA i sc.nextInt() sc.nextInt sc long total = 0; total 0 for (int i = 0; i < n; i++) {
			long b = sc.nextInt();
			if (b > arrA[i]) {
				total += arrA[i];
				b -= arrA[i];
				total += Math.min(arrA[i + 1], b);
				arrA[i + 1] = Math.max(0, arrA[i + 1] - b);
			} else {
				total += b;
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			long b = sc.nextInt();
			if (b > arrA[i]) {
				total += arrA[i];
				b -= arrA[i];
				total += Math.min(arrA[i + 1], b);
				arrA[i + 1] = Math.max(0, arrA[i + 1] - b);
			} else {
				total += b;
			}
		} {
			long b = sc.nextInt();
			if (b > arrA[i]) {
				total += arrA[i];
				b -= arrA[i];
				total += Math.min(arrA[i + 1], b);
				arrA[i + 1] = Math.max(0, arrA[i + 1] - b);
			} else {
				total += b;
			}
		} long b = sc.nextInt(); b sc.nextInt() sc.nextInt sc if (b > arrA[i]) {
				total += arrA[i];
				b -= arrA[i];
				total += Math.min(arrA[i + 1], b);
				arrA[i + 1] = Math.max(0, arrA[i + 1] - b);
			} else {
				total += b;
			} b > arrA[i] b arrA[i] arrA i {
				total += arrA[i];
				b -= arrA[i];
				total += Math.min(arrA[i + 1], b);
				arrA[i + 1] = Math.max(0, arrA[i + 1] - b);
			} total += arrA[i] total arrA[i] arrA i b -= arrA[i] b arrA[i] arrA i total += Math.min(arrA[i + 1], b) total Math.min(arrA[i + 1], b) Math.min Math arrA[i + 1] arrA i + 1 i 1 b arrA[i + 1] = Math.max(0, arrA[i + 1] - b) arrA[i + 1] arrA i + 1 i 1 Math.max(0, arrA[i + 1] - b) Math.max Math 0 arrA[i + 1] - b arrA[i + 1] arrA i + 1 i 1 b {
				total += b;
			} total += b total b 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 n = sc.nextInt();
		long[] arrA = new long[n + 1];
		for (int i = 0; i <= n; i++) {
			arrA[i] = sc.nextInt();
		}
		long total = 0;
		for (int i = 0; i < n; i++) {
			long b = sc.nextInt();
			if (b > arrA[i]) {
				total += arrA[i];
				b -= arrA[i];
				total += Math.min(arrA[i + 1], b);
				arrA[i + 1] = Math.max(0, arrA[i + 1] - b);
			} else {
				total += b;
			}
		}
		System.out.println(total);
	}
} public class Main {

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] arrA = new long[n + 1];
		for (int i = 0; i <= n; i++) {
			arrA[i] = sc.nextInt();
		}
		long total = 0;
		for (int i = 0; i < n; i++) {
			long b = sc.nextInt();
			if (b > arrA[i]) {
				total += arrA[i];
				b -= arrA[i];
				total += Math.min(arrA[i + 1], b);
				arrA[i + 1] = Math.max(0, arrA[i + 1] - b);
			} else {
				total += b;
			}
		}
		System.out.println(total);
	}
} Main
import java.util.*;

public class Main {

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