import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n];
		for (int i = 0; i < n + 1; i++)
			a[i] = in.nextInt();
		for (int i = 0; i < n; i++)
			b[i] = in.nextInt();
		System.out.println(solve(a, b));
		in.close();
	}

	private static long solve(int[] a, int[] b) {
		long r = 0;
		for (int i = 0; i < b.length; i++)
			for (int j = i; j <= i + 1; j++)
				if (a[j] > b[i]) {
					r += b[i];
					a[j] -= b[i];
					b[i] = 0;
				} else {
					r += a[j];
					b[i] -= a[j];
					a[j] = 0;
				}
		return r;
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.Comparator; Comparator java.util import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n];
		for (int i = 0; i < n + 1; i++)
			a[i] = in.nextInt();
		for (int i = 0; i < n; i++)
			b[i] = in.nextInt();
		System.out.println(solve(a, b));
		in.close();
	}

	private static long solve(int[] a, int[] b) {
		long r = 0;
		for (int i = 0; i < b.length; i++)
			for (int j = i; j <= i + 1; j++)
				if (a[j] > b[i]) {
					r += b[i];
					a[j] -= b[i];
					b[i] = 0;
				} else {
					r += a[j];
					b[i] -= a[j];
					a[j] = 0;
				}
		return r;
	}
} Main public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n];
		for (int i = 0; i < n + 1; i++)
			a[i] = in.nextInt();
		for (int i = 0; i < n; i++)
			b[i] = in.nextInt();
		System.out.println(solve(a, b));
		in.close();
	} main {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n];
		for (int i = 0; i < n + 1; i++)
			a[i] = in.nextInt();
		for (int i = 0; i < n; i++)
			b[i] = in.nextInt();
		System.out.println(solve(a, b));
		in.close();
	} Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in))); in new Scanner(new BufferedReader(new InputStreamReader(System.in))) int n = in.nextInt(); n in.nextInt() in.nextInt in 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 for (int i = 0; i < n + 1; i++)
			a[i] = in.nextInt(); int i = 0; int i = 0; i 0 i < n + 1 i n + 1 n 1 i++ i++ i a[i] = in.nextInt(); a[i] = in.nextInt() a[i] a i in.nextInt() in.nextInt in for (int i = 0; i < n; i++)
			b[i] = in.nextInt(); int i = 0; int i = 0; i 0 i < n i n i++ i++ i b[i] = in.nextInt(); b[i] = in.nextInt() b[i] b i in.nextInt() in.nextInt in System.out.println(solve(a, b)) System.out.println System.out System System.out solve(a, b) solve a b in.close() in.close in String[] args args private static long solve(int[] a, int[] b) {
		long r = 0;
		for (int i = 0; i < b.length; i++)
			for (int j = i; j <= i + 1; j++)
				if (a[j] > b[i]) {
					r += b[i];
					a[j] -= b[i];
					b[i] = 0;
				} else {
					r += a[j];
					b[i] -= a[j];
					a[j] = 0;
				}
		return r;
	} solve {
		long r = 0;
		for (int i = 0; i < b.length; i++)
			for (int j = i; j <= i + 1; j++)
				if (a[j] > b[i]) {
					r += b[i];
					a[j] -= b[i];
					b[i] = 0;
				} else {
					r += a[j];
					b[i] -= a[j];
					a[j] = 0;
				}
		return r;
	} long r = 0; r 0 for (int i = 0; i < b.length; i++)
			for (int j = i; j <= i + 1; j++)
				if (a[j] > b[i]) {
					r += b[i];
					a[j] -= b[i];
					b[i] = 0;
				} else {
					r += a[j];
					b[i] -= a[j];
					a[j] = 0;
				} int i = 0; int i = 0; i 0 i < b.length i b.length b b.length i++ i++ i for (int j = i; j <= i + 1; j++)
				if (a[j] > b[i]) {
					r += b[i];
					a[j] -= b[i];
					b[i] = 0;
				} else {
					r += a[j];
					b[i] -= a[j];
					a[j] = 0;
				} for (int j = i; j <= i + 1; j++)
				if (a[j] > b[i]) {
					r += b[i];
					a[j] -= b[i];
					b[i] = 0;
				} else {
					r += a[j];
					b[i] -= a[j];
					a[j] = 0;
				} int j = i; int j = i; j i j <= i + 1 j i + 1 i 1 j++ j++ j if (a[j] > b[i]) {
					r += b[i];
					a[j] -= b[i];
					b[i] = 0;
				} else {
					r += a[j];
					b[i] -= a[j];
					a[j] = 0;
				} if (a[j] > b[i]) {
					r += b[i];
					a[j] -= b[i];
					b[i] = 0;
				} else {
					r += a[j];
					b[i] -= a[j];
					a[j] = 0;
				} a[j] > b[i] a[j] a j b[i] b i {
					r += b[i];
					a[j] -= b[i];
					b[i] = 0;
				} r += b[i] r b[i] b i a[j] -= b[i] a[j] a j b[i] b i b[i] = 0 b[i] b i 0 {
					r += a[j];
					b[i] -= a[j];
					a[j] = 0;
				} r += a[j] r a[j] a j b[i] -= a[j] b[i] b i a[j] a j a[j] = 0 a[j] a j 0 return r; r int[] a a int[] b b public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n];
		for (int i = 0; i < n + 1; i++)
			a[i] = in.nextInt();
		for (int i = 0; i < n; i++)
			b[i] = in.nextInt();
		System.out.println(solve(a, b));
		in.close();
	}

	private static long solve(int[] a, int[] b) {
		long r = 0;
		for (int i = 0; i < b.length; i++)
			for (int j = i; j <= i + 1; j++)
				if (a[j] > b[i]) {
					r += b[i];
					a[j] -= b[i];
					b[i] = 0;
				} else {
					r += a[j];
					b[i] -= a[j];
					a[j] = 0;
				}
		return r;
	}
} public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n];
		for (int i = 0; i < n + 1; i++)
			a[i] = in.nextInt();
		for (int i = 0; i < n; i++)
			b[i] = in.nextInt();
		System.out.println(solve(a, b));
		in.close();
	}

	private static long solve(int[] a, int[] b) {
		long r = 0;
		for (int i = 0; i < b.length; i++)
			for (int j = i; j <= i + 1; j++)
				if (a[j] > b[i]) {
					r += b[i];
					a[j] -= b[i];
					b[i] = 0;
				} else {
					r += a[j];
					b[i] -= a[j];
					a[j] = 0;
				}
		return r;
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n];
		for (int i = 0; i < n + 1; i++)
			a[i] = in.nextInt();
		for (int i = 0; i < n; i++)
			b[i] = in.nextInt();
		System.out.println(solve(a, b));
		in.close();
	}

	private static long solve(int[] a, int[] b) {
		long r = 0;
		for (int i = 0; i < b.length; i++)
			for (int j = i; j <= i + 1; j++)
				if (a[j] > b[i]) {
					r += b[i];
					a[j] -= b[i];
					b[i] = 0;
				} else {
					r += a[j];
					b[i] -= a[j];
					a[j] = 0;
				}
		return r;
	}
}
