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++) {
			int temp = Math.min(a[i], b[i]);
			a[i] -= temp;
			b[i] -= temp;
			ans += temp;
			
			temp = Math.min(a[i + 1], b[i]);
			a[i + 1] -= temp;
			b[i] -= temp;
			ans += temp;
		}

		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++) {
			int temp = Math.min(a[i], b[i]);
			a[i] -= temp;
			b[i] -= temp;
			ans += temp;
			
			temp = Math.min(a[i + 1], b[i]);
			a[i + 1] -= temp;
			b[i] -= temp;
			ans += temp;
		}

		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++) {
			int temp = Math.min(a[i], b[i]);
			a[i] -= temp;
			b[i] -= temp;
			ans += temp;
			
			temp = Math.min(a[i + 1], b[i]);
			a[i + 1] -= temp;
			b[i] -= temp;
			ans += temp;
		}

		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++) {
			int temp = Math.min(a[i], b[i]);
			a[i] -= temp;
			b[i] -= temp;
			ans += temp;
			
			temp = Math.min(a[i + 1], b[i]);
			a[i + 1] -= temp;
			b[i] -= temp;
			ans += temp;
		}

		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++) {
			int temp = Math.min(a[i], b[i]);
			a[i] -= temp;
			b[i] -= temp;
			ans += temp;
			
			temp = Math.min(a[i + 1], b[i]);
			a[i + 1] -= temp;
			b[i] -= temp;
			ans += temp;
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			int temp = Math.min(a[i], b[i]);
			a[i] -= temp;
			b[i] -= temp;
			ans += temp;
			
			temp = Math.min(a[i + 1], b[i]);
			a[i + 1] -= temp;
			b[i] -= temp;
			ans += temp;
		} {
			int temp = Math.min(a[i], b[i]);
			a[i] -= temp;
			b[i] -= temp;
			ans += temp;
			
			temp = Math.min(a[i + 1], b[i]);
			a[i + 1] -= temp;
			b[i] -= temp;
			ans += temp;
		} int temp = Math.min(a[i], b[i]); temp Math.min(a[i], b[i]) Math.min Math a[i] a i b[i] b i a[i] -= temp a[i] a i temp b[i] -= temp b[i] b i temp ans += temp ans temp temp = Math.min(a[i + 1], b[i]) temp Math.min(a[i + 1], b[i]) Math.min Math a[i + 1] a i + 1 i 1 b[i] b i a[i + 1] -= temp a[i + 1] a i + 1 i 1 temp b[i] -= temp b[i] b i temp ans += temp ans temp 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++) {
			int temp = Math.min(a[i], b[i]);
			a[i] -= temp;
			b[i] -= temp;
			ans += temp;
			
			temp = Math.min(a[i + 1], b[i]);
			a[i + 1] -= temp;
			b[i] -= temp;
			ans += temp;
		}

		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++) {
			int temp = Math.min(a[i], b[i]);
			a[i] -= temp;
			b[i] -= temp;
			ans += temp;
			
			temp = Math.min(a[i + 1], b[i]);
			a[i + 1] -= temp;
			b[i] -= temp;
			ans += temp;
		}

		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++) {
			int temp = Math.min(a[i], b[i]);
			a[i] -= temp;
			b[i] -= temp;
			ans += temp;
			
			temp = Math.min(a[i + 1], b[i]);
			a[i + 1] -= temp;
			b[i] -= temp;
			ans += temp;
		}

		System.out.println(ans);
	}
}