import java.util.Scanner;

public class Main {

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

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

		long h = 0;
		long b;
		long d = 0;
		for (int i = 0; i <= n; i++) {
			if (i!=n) {
				b = sc.nextLong();
			} else {
				b = 0;
			}
			if (h <= a[i]) {
				d += h;
				a[i] -= h;
			} else  {
				d += a[i];
				a[i] = 0;
			}
			if (b <= a[i]) {
				d += b;
				h = 0;
			} else {
				d += a[i];
				h = b - a[i];
			}
		}
		System.out.println(d);
	}
} import java.util.Scanner; Scanner java.util public class Main {

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

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

		long h = 0;
		long b;
		long d = 0;
		for (int i = 0; i <= n; i++) {
			if (i!=n) {
				b = sc.nextLong();
			} else {
				b = 0;
			}
			if (h <= a[i]) {
				d += h;
				a[i] -= h;
			} else  {
				d += a[i];
				a[i] = 0;
			}
			if (b <= a[i]) {
				d += b;
				h = 0;
			} else {
				d += a[i];
				h = b - a[i];
			}
		}
		System.out.println(d);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n + 1];

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

		long h = 0;
		long b;
		long d = 0;
		for (int i = 0; i <= n; i++) {
			if (i!=n) {
				b = sc.nextLong();
			} else {
				b = 0;
			}
			if (h <= a[i]) {
				d += h;
				a[i] -= h;
			} else  {
				d += a[i];
				a[i] = 0;
			}
			if (b <= a[i]) {
				d += b;
				h = 0;
			} else {
				d += a[i];
				h = b - a[i];
			}
		}
		System.out.println(d);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n + 1];

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

		long h = 0;
		long b;
		long d = 0;
		for (int i = 0; i <= n; i++) {
			if (i!=n) {
				b = sc.nextLong();
			} else {
				b = 0;
			}
			if (h <= a[i]) {
				d += h;
				a[i] -= h;
			} else  {
				d += a[i];
				a[i] = 0;
			}
			if (b <= a[i]) {
				d += b;
				h = 0;
			} else {
				d += a[i];
				h = b - a[i];
			}
		}
		System.out.println(d);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc long[] a = new long[n + 1]; a new long[n + 1] n + 1 n 1 for (int i = 0; i <= n; i++) {
			a[i] = sc.nextLong();
		} int i = 0; int i = 0; i 0 i <= n i n i++ i++ i {
			a[i] = sc.nextLong();
		} {
			a[i] = sc.nextLong();
		} a[i] = sc.nextLong() a[i] a i sc.nextLong() sc.nextLong sc long h = 0; h 0 long b; b long d = 0; d 0 for (int i = 0; i <= n; i++) {
			if (i!=n) {
				b = sc.nextLong();
			} else {
				b = 0;
			}
			if (h <= a[i]) {
				d += h;
				a[i] -= h;
			} else  {
				d += a[i];
				a[i] = 0;
			}
			if (b <= a[i]) {
				d += b;
				h = 0;
			} else {
				d += a[i];
				h = b - a[i];
			}
		} int i = 0; int i = 0; i 0 i <= n i n i++ i++ i {
			if (i!=n) {
				b = sc.nextLong();
			} else {
				b = 0;
			}
			if (h <= a[i]) {
				d += h;
				a[i] -= h;
			} else  {
				d += a[i];
				a[i] = 0;
			}
			if (b <= a[i]) {
				d += b;
				h = 0;
			} else {
				d += a[i];
				h = b - a[i];
			}
		} {
			if (i!=n) {
				b = sc.nextLong();
			} else {
				b = 0;
			}
			if (h <= a[i]) {
				d += h;
				a[i] -= h;
			} else  {
				d += a[i];
				a[i] = 0;
			}
			if (b <= a[i]) {
				d += b;
				h = 0;
			} else {
				d += a[i];
				h = b - a[i];
			}
		} if (i!=n) {
				b = sc.nextLong();
			} else {
				b = 0;
			} i!=n i n {
				b = sc.nextLong();
			} b = sc.nextLong() b sc.nextLong() sc.nextLong sc {
				b = 0;
			} b = 0 b 0 if (h <= a[i]) {
				d += h;
				a[i] -= h;
			} else  {
				d += a[i];
				a[i] = 0;
			} h <= a[i] h a[i] a i {
				d += h;
				a[i] -= h;
			} d += h d h a[i] -= h a[i] a i h {
				d += a[i];
				a[i] = 0;
			} d += a[i] d a[i] a i a[i] = 0 a[i] a i 0 if (b <= a[i]) {
				d += b;
				h = 0;
			} else {
				d += a[i];
				h = b - a[i];
			} b <= a[i] b a[i] a i {
				d += b;
				h = 0;
			} d += b d b h = 0 h 0 {
				d += a[i];
				h = b - a[i];
			} d += a[i] d a[i] a i h = b - a[i] h b - a[i] b a[i] a i System.out.println(d) System.out.println System.out System System.out d String[] args args public class Main {

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

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

		long h = 0;
		long b;
		long d = 0;
		for (int i = 0; i <= n; i++) {
			if (i!=n) {
				b = sc.nextLong();
			} else {
				b = 0;
			}
			if (h <= a[i]) {
				d += h;
				a[i] -= h;
			} else  {
				d += a[i];
				a[i] = 0;
			}
			if (b <= a[i]) {
				d += b;
				h = 0;
			} else {
				d += a[i];
				h = b - a[i];
			}
		}
		System.out.println(d);
	}
} public class Main {

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

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

		long h = 0;
		long b;
		long d = 0;
		for (int i = 0; i <= n; i++) {
			if (i!=n) {
				b = sc.nextLong();
			} else {
				b = 0;
			}
			if (h <= a[i]) {
				d += h;
				a[i] -= h;
			} else  {
				d += a[i];
				a[i] = 0;
			}
			if (b <= a[i]) {
				d += b;
				h = 0;
			} else {
				d += a[i];
				h = b - a[i];
			}
		}
		System.out.println(d);
	}
} Main
import java.util.Scanner;

public class Main {

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

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

		long h = 0;
		long b;
		long d = 0;
		for (int i = 0; i <= n; i++) {
			if (i!=n) {
				b = sc.nextLong();
			} else {
				b = 0;
			}
			if (h <= a[i]) {
				d += h;
				a[i] -= h;
			} else  {
				d += a[i];
				a[i] = 0;
			}
			if (b <= a[i]) {
				d += b;
				h = 0;
			} else {
				d += a[i];
				h = b - a[i];
			}
		}
		System.out.println(d);
	}
}
