
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] a = new int[n + 1];
			int[] b = new int[n];
			long result = 0;

			for (int i = 0; i <= n; i++) {
				a[i] = sc.nextInt();
			}
			for (int i = 0; i < n; i++) {
				b[i] = sc.nextInt();
			}

			int before = 0;
			for (int i = 0; i < n; i++) {
				// bがのこり倒せる数
				int tmp = b[i] - (a[i] - before);
				if (tmp < 0) {
					// 全部
					result += b[i];
					before = 0;
				} else {
					// a[i]を全滅
					result += (a[i] - before);
					// 倒したかず
					int tmp2 = a[i + 1] - tmp;
					if  (tmp2 < 0) {
						result += a[i + 1];
						before = a[i + 1];
					} else {
						result += tmp;
						before = tmp;
					}
				}
			}

			System.out.println(result);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] a = new int[n + 1];
			int[] b = new int[n];
			long result = 0;

			for (int i = 0; i <= n; i++) {
				a[i] = sc.nextInt();
			}
			for (int i = 0; i < n; i++) {
				b[i] = sc.nextInt();
			}

			int before = 0;
			for (int i = 0; i < n; i++) {
				// bがのこり倒せる数
				int tmp = b[i] - (a[i] - before);
				if (tmp < 0) {
					// 全部
					result += b[i];
					before = 0;
				} else {
					// a[i]を全滅
					result += (a[i] - before);
					// 倒したかず
					int tmp2 = a[i + 1] - tmp;
					if  (tmp2 < 0) {
						result += a[i + 1];
						before = a[i + 1];
					} else {
						result += tmp;
						before = tmp;
					}
				}
			}

			System.out.println(result);
		}
	}
} Main public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] a = new int[n + 1];
			int[] b = new int[n];
			long result = 0;

			for (int i = 0; i <= n; i++) {
				a[i] = sc.nextInt();
			}
			for (int i = 0; i < n; i++) {
				b[i] = sc.nextInt();
			}

			int before = 0;
			for (int i = 0; i < n; i++) {
				// bがのこり倒せる数
				int tmp = b[i] - (a[i] - before);
				if (tmp < 0) {
					// 全部
					result += b[i];
					before = 0;
				} else {
					// a[i]を全滅
					result += (a[i] - before);
					// 倒したかず
					int tmp2 = a[i + 1] - tmp;
					if  (tmp2 < 0) {
						result += a[i + 1];
						before = a[i + 1];
					} else {
						result += tmp;
						before = tmp;
					}
				}
			}

			System.out.println(result);
		}
	} main {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] a = new int[n + 1];
			int[] b = new int[n];
			long result = 0;

			for (int i = 0; i <= n; i++) {
				a[i] = sc.nextInt();
			}
			for (int i = 0; i < n; i++) {
				b[i] = sc.nextInt();
			}

			int before = 0;
			for (int i = 0; i < n; i++) {
				// bがのこり倒せる数
				int tmp = b[i] - (a[i] - before);
				if (tmp < 0) {
					// 全部
					result += b[i];
					before = 0;
				} else {
					// a[i]を全滅
					result += (a[i] - before);
					// 倒したかず
					int tmp2 = a[i + 1] - tmp;
					if  (tmp2 < 0) {
						result += a[i + 1];
						before = a[i + 1];
					} else {
						result += tmp;
						before = tmp;
					}
				}
			}

			System.out.println(result);
		}
	} try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] a = new int[n + 1];
			int[] b = new int[n];
			long result = 0;

			for (int i = 0; i <= n; i++) {
				a[i] = sc.nextInt();
			}
			for (int i = 0; i < n; i++) {
				b[i] = sc.nextInt();
			}

			int before = 0;
			for (int i = 0; i < n; i++) {
				// bがのこり倒せる数
				int tmp = b[i] - (a[i] - before);
				if (tmp < 0) {
					// 全部
					result += b[i];
					before = 0;
				} else {
					// a[i]を全滅
					result += (a[i] - before);
					// 倒したかず
					int tmp2 = a[i + 1] - tmp;
					if  (tmp2 < 0) {
						result += a[i + 1];
						before = a[i + 1];
					} else {
						result += tmp;
						before = tmp;
					}
				}
			}

			System.out.println(result);
		} {
			int n = sc.nextInt();
			int[] a = new int[n + 1];
			int[] b = new int[n];
			long result = 0;

			for (int i = 0; i <= n; i++) {
				a[i] = sc.nextInt();
			}
			for (int i = 0; i < n; i++) {
				b[i] = sc.nextInt();
			}

			int before = 0;
			for (int i = 0; i < n; i++) {
				// bがのこり倒せる数
				int tmp = b[i] - (a[i] - before);
				if (tmp < 0) {
					// 全部
					result += b[i];
					before = 0;
				} else {
					// a[i]を全滅
					result += (a[i] - before);
					// 倒したかず
					int tmp2 = a[i + 1] - tmp;
					if  (tmp2 < 0) {
						result += a[i + 1];
						before = a[i + 1];
					} else {
						result += tmp;
						before = tmp;
					}
				}
			}

			System.out.println(result);
		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.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 int[] b = new int[n]; b new int[n] n long result = 0; result 0 for (int i = 0; i <= n; i++) {
				a[i] = sc.nextInt();
			} int i = 0; int i = 0; i 0 i <= n i n 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 before = 0; before 0 for (int i = 0; i < n; i++) {
				// bがのこり倒せる数
				int tmp = b[i] - (a[i] - before);
				if (tmp < 0) {
					// 全部
					result += b[i];
					before = 0;
				} else {
					// a[i]を全滅
					result += (a[i] - before);
					// 倒したかず
					int tmp2 = a[i + 1] - tmp;
					if  (tmp2 < 0) {
						result += a[i + 1];
						before = a[i + 1];
					} else {
						result += tmp;
						before = tmp;
					}
				}
			} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
				// bがのこり倒せる数
				int tmp = b[i] - (a[i] - before);
				if (tmp < 0) {
					// 全部
					result += b[i];
					before = 0;
				} else {
					// a[i]を全滅
					result += (a[i] - before);
					// 倒したかず
					int tmp2 = a[i + 1] - tmp;
					if  (tmp2 < 0) {
						result += a[i + 1];
						before = a[i + 1];
					} else {
						result += tmp;
						before = tmp;
					}
				}
			} {
				// bがのこり倒せる数
				int tmp = b[i] - (a[i] - before);
				if (tmp < 0) {
					// 全部
					result += b[i];
					before = 0;
				} else {
					// a[i]を全滅
					result += (a[i] - before);
					// 倒したかず
					int tmp2 = a[i + 1] - tmp;
					if  (tmp2 < 0) {
						result += a[i + 1];
						before = a[i + 1];
					} else {
						result += tmp;
						before = tmp;
					}
				}
			} int tmp = b[i] - (a[i] - before); tmp b[i] - (a[i] - before) b[i] b i (a[i] - before) a[i] a i before if (tmp < 0) {
					// 全部
					result += b[i];
					before = 0;
				} else {
					// a[i]を全滅
					result += (a[i] - before);
					// 倒したかず
					int tmp2 = a[i + 1] - tmp;
					if  (tmp2 < 0) {
						result += a[i + 1];
						before = a[i + 1];
					} else {
						result += tmp;
						before = tmp;
					}
				} tmp < 0 tmp 0 {
					// 全部
					result += b[i];
					before = 0;
				} result += b[i] result b[i] b i before = 0 before 0 {
					// a[i]を全滅
					result += (a[i] - before);
					// 倒したかず
					int tmp2 = a[i + 1] - tmp;
					if  (tmp2 < 0) {
						result += a[i + 1];
						before = a[i + 1];
					} else {
						result += tmp;
						before = tmp;
					}
				} result += (a[i] - before) result (a[i] - before) a[i] a i before int tmp2 = a[i + 1] - tmp; tmp2 a[i + 1] - tmp a[i + 1] a i + 1 i 1 tmp if  (tmp2 < 0) {
						result += a[i + 1];
						before = a[i + 1];
					} else {
						result += tmp;
						before = tmp;
					} tmp2 < 0 tmp2 0 {
						result += a[i + 1];
						before = a[i + 1];
					} result += a[i + 1] result a[i + 1] a i + 1 i 1 before = a[i + 1] before a[i + 1] a i + 1 i 1 {
						result += tmp;
						before = tmp;
					} result += tmp result tmp before = tmp before tmp System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] a = new int[n + 1];
			int[] b = new int[n];
			long result = 0;

			for (int i = 0; i <= n; i++) {
				a[i] = sc.nextInt();
			}
			for (int i = 0; i < n; i++) {
				b[i] = sc.nextInt();
			}

			int before = 0;
			for (int i = 0; i < n; i++) {
				// bがのこり倒せる数
				int tmp = b[i] - (a[i] - before);
				if (tmp < 0) {
					// 全部
					result += b[i];
					before = 0;
				} else {
					// a[i]を全滅
					result += (a[i] - before);
					// 倒したかず
					int tmp2 = a[i + 1] - tmp;
					if  (tmp2 < 0) {
						result += a[i + 1];
						before = a[i + 1];
					} else {
						result += tmp;
						before = tmp;
					}
				}
			}

			System.out.println(result);
		}
	}
} public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] a = new int[n + 1];
			int[] b = new int[n];
			long result = 0;

			for (int i = 0; i <= n; i++) {
				a[i] = sc.nextInt();
			}
			for (int i = 0; i < n; i++) {
				b[i] = sc.nextInt();
			}

			int before = 0;
			for (int i = 0; i < n; i++) {
				// bがのこり倒せる数
				int tmp = b[i] - (a[i] - before);
				if (tmp < 0) {
					// 全部
					result += b[i];
					before = 0;
				} else {
					// a[i]を全滅
					result += (a[i] - before);
					// 倒したかず
					int tmp2 = a[i + 1] - tmp;
					if  (tmp2 < 0) {
						result += a[i + 1];
						before = a[i + 1];
					} else {
						result += tmp;
						before = tmp;
					}
				}
			}

			System.out.println(result);
		}
	}
} Main

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] a = new int[n + 1];
			int[] b = new int[n];
			long result = 0;

			for (int i = 0; i <= n; i++) {
				a[i] = sc.nextInt();
			}
			for (int i = 0; i < n; i++) {
				b[i] = sc.nextInt();
			}

			int before = 0;
			for (int i = 0; i < n; i++) {
				// bがのこり倒せる数
				int tmp = b[i] - (a[i] - before);
				if (tmp < 0) {
					// 全部
					result += b[i];
					before = 0;
				} else {
					// a[i]を全滅
					result += (a[i] - before);
					// 倒したかず
					int tmp2 = a[i + 1] - tmp;
					if  (tmp2 < 0) {
						result += a[i + 1];
						before = a[i + 1];
					} else {
						result += tmp;
						before = tmp;
					}
				}
			}

			System.out.println(result);
		}
	}
}
