import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		int a[] = new int[n + 1];
		int b[] = new int[n];

		String str[] = br.readLine().split(" ");

		for (int i = 0; i < n + 1; i++) {
			a[i] = Integer.parseInt(str[i]);
		}

		str = br.readLine().split(" ");

		for (int i = 0; i < n; i++) {
			b[i] = Integer.parseInt(str[i]);
		}

		long ans = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] > 0) {
				ans += Math.min(a[i], b[i]);
				int temp = a[i];
				a[i] -= b[i];
				b[i] -= temp;
			}

			if (a[i] <= 0 && b[i] > 0) {
				ans += Math.min(a[i + 1], b[i]);
				int temp1 = a[i + 1];
				a[i + 1] -= b[i];
				b[i] -= temp1;
			}
		}

		System.out.println(ans);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		int a[] = new int[n + 1];
		int b[] = new int[n];

		String str[] = br.readLine().split(" ");

		for (int i = 0; i < n + 1; i++) {
			a[i] = Integer.parseInt(str[i]);
		}

		str = br.readLine().split(" ");

		for (int i = 0; i < n; i++) {
			b[i] = Integer.parseInt(str[i]);
		}

		long ans = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] > 0) {
				ans += Math.min(a[i], b[i]);
				int temp = a[i];
				a[i] -= b[i];
				b[i] -= temp;
			}

			if (a[i] <= 0 && b[i] > 0) {
				ans += Math.min(a[i + 1], b[i]);
				int temp1 = a[i + 1];
				a[i + 1] -= b[i];
				b[i] -= temp1;
			}
		}

		System.out.println(ans);
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		int a[] = new int[n + 1];
		int b[] = new int[n];

		String str[] = br.readLine().split(" ");

		for (int i = 0; i < n + 1; i++) {
			a[i] = Integer.parseInt(str[i]);
		}

		str = br.readLine().split(" ");

		for (int i = 0; i < n; i++) {
			b[i] = Integer.parseInt(str[i]);
		}

		long ans = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] > 0) {
				ans += Math.min(a[i], b[i]);
				int temp = a[i];
				a[i] -= b[i];
				b[i] -= temp;
			}

			if (a[i] <= 0 && b[i] > 0) {
				ans += Math.min(a[i + 1], b[i]);
				int temp1 = a[i + 1];
				a[i + 1] -= b[i];
				b[i] -= temp1;
			}
		}

		System.out.println(ans);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		int a[] = new int[n + 1];
		int b[] = new int[n];

		String str[] = br.readLine().split(" ");

		for (int i = 0; i < n + 1; i++) {
			a[i] = Integer.parseInt(str[i]);
		}

		str = br.readLine().split(" ");

		for (int i = 0; i < n; i++) {
			b[i] = Integer.parseInt(str[i]);
		}

		long ans = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] > 0) {
				ans += Math.min(a[i], b[i]);
				int temp = a[i];
				a[i] -= b[i];
				b[i] -= temp;
			}

			if (a[i] <= 0 && b[i] > 0) {
				ans += Math.min(a[i + 1], b[i]);
				int temp1 = a[i + 1];
				a[i + 1] -= b[i];
				b[i] -= temp1;
			}
		}

		System.out.println(ans);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int n = Integer.parseInt(br.readLine()); n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br 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 String str[] = br.readLine().split(" "); str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " for (int i = 0; i < n + 1; i++) {
			a[i] = Integer.parseInt(str[i]);
		} int i = 0; int i = 0; i 0 i < n + 1 i n + 1 n 1 i++ i++ i {
			a[i] = Integer.parseInt(str[i]);
		} {
			a[i] = Integer.parseInt(str[i]);
		} a[i] = Integer.parseInt(str[i]) a[i] a i Integer.parseInt(str[i]) Integer.parseInt Integer str[i] str i str = br.readLine().split(" ") str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " for (int i = 0; i < n; i++) {
			b[i] = Integer.parseInt(str[i]);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			b[i] = Integer.parseInt(str[i]);
		} {
			b[i] = Integer.parseInt(str[i]);
		} b[i] = Integer.parseInt(str[i]) b[i] b i Integer.parseInt(str[i]) Integer.parseInt Integer str[i] str i long ans = 0; ans 0 for (int i = 0; i < n; i++) {
			if (a[i] > 0) {
				ans += Math.min(a[i], b[i]);
				int temp = a[i];
				a[i] -= b[i];
				b[i] -= temp;
			}

			if (a[i] <= 0 && b[i] > 0) {
				ans += Math.min(a[i + 1], b[i]);
				int temp1 = a[i + 1];
				a[i + 1] -= b[i];
				b[i] -= temp1;
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			if (a[i] > 0) {
				ans += Math.min(a[i], b[i]);
				int temp = a[i];
				a[i] -= b[i];
				b[i] -= temp;
			}

			if (a[i] <= 0 && b[i] > 0) {
				ans += Math.min(a[i + 1], b[i]);
				int temp1 = a[i + 1];
				a[i + 1] -= b[i];
				b[i] -= temp1;
			}
		} {
			if (a[i] > 0) {
				ans += Math.min(a[i], b[i]);
				int temp = a[i];
				a[i] -= b[i];
				b[i] -= temp;
			}

			if (a[i] <= 0 && b[i] > 0) {
				ans += Math.min(a[i + 1], b[i]);
				int temp1 = a[i + 1];
				a[i + 1] -= b[i];
				b[i] -= temp1;
			}
		} if (a[i] > 0) {
				ans += Math.min(a[i], b[i]);
				int temp = a[i];
				a[i] -= b[i];
				b[i] -= temp;
			} a[i] > 0 a[i] a i 0 {
				ans += Math.min(a[i], b[i]);
				int temp = a[i];
				a[i] -= b[i];
				b[i] -= temp;
			} ans += Math.min(a[i], b[i]) ans Math.min(a[i], b[i]) Math.min Math a[i] a i b[i] b i int temp = a[i]; temp a[i] a i a[i] -= b[i] a[i] a i b[i] b i b[i] -= temp b[i] b i temp if (a[i] <= 0 && b[i] > 0) {
				ans += Math.min(a[i + 1], b[i]);
				int temp1 = a[i + 1];
				a[i + 1] -= b[i];
				b[i] -= temp1;
			} a[i] <= 0 && b[i] > 0 a[i] <= 0 a[i] a i 0 b[i] > 0 b[i] b i 0 {
				ans += Math.min(a[i + 1], b[i]);
				int temp1 = a[i + 1];
				a[i + 1] -= b[i];
				b[i] -= temp1;
			} ans += Math.min(a[i + 1], b[i]) ans Math.min(a[i + 1], b[i]) Math.min Math a[i + 1] a i + 1 i 1 b[i] b i int temp1 = a[i + 1]; temp1 a[i + 1] a i + 1 i 1 a[i + 1] -= b[i] a[i + 1] a i + 1 i 1 b[i] b i b[i] -= temp1 b[i] b i temp1 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		int a[] = new int[n + 1];
		int b[] = new int[n];

		String str[] = br.readLine().split(" ");

		for (int i = 0; i < n + 1; i++) {
			a[i] = Integer.parseInt(str[i]);
		}

		str = br.readLine().split(" ");

		for (int i = 0; i < n; i++) {
			b[i] = Integer.parseInt(str[i]);
		}

		long ans = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] > 0) {
				ans += Math.min(a[i], b[i]);
				int temp = a[i];
				a[i] -= b[i];
				b[i] -= temp;
			}

			if (a[i] <= 0 && b[i] > 0) {
				ans += Math.min(a[i + 1], b[i]);
				int temp1 = a[i + 1];
				a[i + 1] -= b[i];
				b[i] -= temp1;
			}
		}

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

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		int a[] = new int[n + 1];
		int b[] = new int[n];

		String str[] = br.readLine().split(" ");

		for (int i = 0; i < n + 1; i++) {
			a[i] = Integer.parseInt(str[i]);
		}

		str = br.readLine().split(" ");

		for (int i = 0; i < n; i++) {
			b[i] = Integer.parseInt(str[i]);
		}

		long ans = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] > 0) {
				ans += Math.min(a[i], b[i]);
				int temp = a[i];
				a[i] -= b[i];
				b[i] -= temp;
			}

			if (a[i] <= 0 && b[i] > 0) {
				ans += Math.min(a[i + 1], b[i]);
				int temp1 = a[i + 1];
				a[i + 1] -= b[i];
				b[i] -= temp1;
			}
		}

		System.out.println(ans);
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		int a[] = new int[n + 1];
		int b[] = new int[n];

		String str[] = br.readLine().split(" ");

		for (int i = 0; i < n + 1; i++) {
			a[i] = Integer.parseInt(str[i]);
		}

		str = br.readLine().split(" ");

		for (int i = 0; i < n; i++) {
			b[i] = Integer.parseInt(str[i]);
		}

		long ans = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] > 0) {
				ans += Math.min(a[i], b[i]);
				int temp = a[i];
				a[i] -= b[i];
				b[i] -= temp;
			}

			if (a[i] <= 0 && b[i] > 0) {
				ans += Math.min(a[i + 1], b[i]);
				int temp1 = a[i + 1];
				a[i + 1] -= b[i];
				b[i] -= temp1;
			}
		}

		System.out.println(ans);
	}
}