import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) {
		long ans = 0;
		ArrayList<Integer> city = new ArrayList<Integer>();
		ArrayList<Integer> hero = new ArrayList<Integer>();
		Scanner read = new Scanner(System.in);
		int n = read.nextInt();
		for (int i = 0; i <= n; i++) {
			int a = read.nextInt();
			city.add(a);
		}
		for (int i = 0; i < n; i++) {
			int b = read.nextInt();
			hero.add(b);
		}
		for (int i = 0; i < n; i++) {
			for (int j = i; j <= i + 1; j++) {
				int small = Math.min(city.get(j), hero.get(i));
				ans += small;
				city.set(j, city.get(j) - small);
				hero.set(i, hero.get(i) - small);
//				System.out.println(city.get(j));
//				System.out.println(hero.get(i));
			}
		}
		System.out.println(ans);
	}
} import java.util.Scanner; Scanner java.util import java.util.ArrayList; ArrayList java.util public class Main {
	public static void main(String[] args) {
		long ans = 0;
		ArrayList<Integer> city = new ArrayList<Integer>();
		ArrayList<Integer> hero = new ArrayList<Integer>();
		Scanner read = new Scanner(System.in);
		int n = read.nextInt();
		for (int i = 0; i <= n; i++) {
			int a = read.nextInt();
			city.add(a);
		}
		for (int i = 0; i < n; i++) {
			int b = read.nextInt();
			hero.add(b);
		}
		for (int i = 0; i < n; i++) {
			for (int j = i; j <= i + 1; j++) {
				int small = Math.min(city.get(j), hero.get(i));
				ans += small;
				city.set(j, city.get(j) - small);
				hero.set(i, hero.get(i) - small);
//				System.out.println(city.get(j));
//				System.out.println(hero.get(i));
			}
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args) {
		long ans = 0;
		ArrayList<Integer> city = new ArrayList<Integer>();
		ArrayList<Integer> hero = new ArrayList<Integer>();
		Scanner read = new Scanner(System.in);
		int n = read.nextInt();
		for (int i = 0; i <= n; i++) {
			int a = read.nextInt();
			city.add(a);
		}
		for (int i = 0; i < n; i++) {
			int b = read.nextInt();
			hero.add(b);
		}
		for (int i = 0; i < n; i++) {
			for (int j = i; j <= i + 1; j++) {
				int small = Math.min(city.get(j), hero.get(i));
				ans += small;
				city.set(j, city.get(j) - small);
				hero.set(i, hero.get(i) - small);
//				System.out.println(city.get(j));
//				System.out.println(hero.get(i));
			}
		}
		System.out.println(ans);
	} main {
		long ans = 0;
		ArrayList<Integer> city = new ArrayList<Integer>();
		ArrayList<Integer> hero = new ArrayList<Integer>();
		Scanner read = new Scanner(System.in);
		int n = read.nextInt();
		for (int i = 0; i <= n; i++) {
			int a = read.nextInt();
			city.add(a);
		}
		for (int i = 0; i < n; i++) {
			int b = read.nextInt();
			hero.add(b);
		}
		for (int i = 0; i < n; i++) {
			for (int j = i; j <= i + 1; j++) {
				int small = Math.min(city.get(j), hero.get(i));
				ans += small;
				city.set(j, city.get(j) - small);
				hero.set(i, hero.get(i) - small);
//				System.out.println(city.get(j));
//				System.out.println(hero.get(i));
			}
		}
		System.out.println(ans);
	} long ans = 0; ans 0 ArrayList<Integer> city = new ArrayList<Integer>(); city new ArrayList<Integer>() ArrayList<Integer> hero = new ArrayList<Integer>(); hero new ArrayList<Integer>() Scanner read = new Scanner(System.in); read new Scanner(System.in) int n = read.nextInt(); n read.nextInt() read.nextInt read for (int i = 0; i <= n; i++) {
			int a = read.nextInt();
			city.add(a);
		} int i = 0; int i = 0; i 0 i <= n i n i++ i++ i {
			int a = read.nextInt();
			city.add(a);
		} {
			int a = read.nextInt();
			city.add(a);
		} int a = read.nextInt(); a read.nextInt() read.nextInt read city.add(a) city.add city a for (int i = 0; i < n; i++) {
			int b = read.nextInt();
			hero.add(b);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			int b = read.nextInt();
			hero.add(b);
		} {
			int b = read.nextInt();
			hero.add(b);
		} int b = read.nextInt(); b read.nextInt() read.nextInt read hero.add(b) hero.add hero b for (int i = 0; i < n; i++) {
			for (int j = i; j <= i + 1; j++) {
				int small = Math.min(city.get(j), hero.get(i));
				ans += small;
				city.set(j, city.get(j) - small);
				hero.set(i, hero.get(i) - small);
//				System.out.println(city.get(j));
//				System.out.println(hero.get(i));
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			for (int j = i; j <= i + 1; j++) {
				int small = Math.min(city.get(j), hero.get(i));
				ans += small;
				city.set(j, city.get(j) - small);
				hero.set(i, hero.get(i) - small);
//				System.out.println(city.get(j));
//				System.out.println(hero.get(i));
			}
		} {
			for (int j = i; j <= i + 1; j++) {
				int small = Math.min(city.get(j), hero.get(i));
				ans += small;
				city.set(j, city.get(j) - small);
				hero.set(i, hero.get(i) - small);
//				System.out.println(city.get(j));
//				System.out.println(hero.get(i));
			}
		} for (int j = i; j <= i + 1; j++) {
				int small = Math.min(city.get(j), hero.get(i));
				ans += small;
				city.set(j, city.get(j) - small);
				hero.set(i, hero.get(i) - small);
//				System.out.println(city.get(j));
//				System.out.println(hero.get(i));
			} int j = i; int j = i; j i j <= i + 1 j i + 1 i 1 j++ j++ j {
				int small = Math.min(city.get(j), hero.get(i));
				ans += small;
				city.set(j, city.get(j) - small);
				hero.set(i, hero.get(i) - small);
//				System.out.println(city.get(j));
//				System.out.println(hero.get(i));
			} {
				int small = Math.min(city.get(j), hero.get(i));
				ans += small;
				city.set(j, city.get(j) - small);
				hero.set(i, hero.get(i) - small);
//				System.out.println(city.get(j));
//				System.out.println(hero.get(i));
			} int small = Math.min(city.get(j), hero.get(i)); small Math.min(city.get(j), hero.get(i)) Math.min Math city.get(j) city.get city j hero.get(i) hero.get hero i ans += small ans small city.set(j, city.get(j) - small) city.set city j city.get(j) - small city.get(j) city.get city j small hero.set(i, hero.get(i) - small) hero.set hero i hero.get(i) - small hero.get(i) hero.get hero i small 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) {
		long ans = 0;
		ArrayList<Integer> city = new ArrayList<Integer>();
		ArrayList<Integer> hero = new ArrayList<Integer>();
		Scanner read = new Scanner(System.in);
		int n = read.nextInt();
		for (int i = 0; i <= n; i++) {
			int a = read.nextInt();
			city.add(a);
		}
		for (int i = 0; i < n; i++) {
			int b = read.nextInt();
			hero.add(b);
		}
		for (int i = 0; i < n; i++) {
			for (int j = i; j <= i + 1; j++) {
				int small = Math.min(city.get(j), hero.get(i));
				ans += small;
				city.set(j, city.get(j) - small);
				hero.set(i, hero.get(i) - small);
//				System.out.println(city.get(j));
//				System.out.println(hero.get(i));
			}
		}
		System.out.println(ans);
	}
} public class Main {
	public static void main(String[] args) {
		long ans = 0;
		ArrayList<Integer> city = new ArrayList<Integer>();
		ArrayList<Integer> hero = new ArrayList<Integer>();
		Scanner read = new Scanner(System.in);
		int n = read.nextInt();
		for (int i = 0; i <= n; i++) {
			int a = read.nextInt();
			city.add(a);
		}
		for (int i = 0; i < n; i++) {
			int b = read.nextInt();
			hero.add(b);
		}
		for (int i = 0; i < n; i++) {
			for (int j = i; j <= i + 1; j++) {
				int small = Math.min(city.get(j), hero.get(i));
				ans += small;
				city.set(j, city.get(j) - small);
				hero.set(i, hero.get(i) - small);
//				System.out.println(city.get(j));
//				System.out.println(hero.get(i));
			}
		}
		System.out.println(ans);
	}
} Main
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) {
		long ans = 0;
		ArrayList<Integer> city = new ArrayList<Integer>();
		ArrayList<Integer> hero = new ArrayList<Integer>();
		Scanner read = new Scanner(System.in);
		int n = read.nextInt();
		for (int i = 0; i <= n; i++) {
			int a = read.nextInt();
			city.add(a);
		}
		for (int i = 0; i < n; i++) {
			int b = read.nextInt();
			hero.add(b);
		}
		for (int i = 0; i < n; i++) {
			for (int j = i; j <= i + 1; j++) {
				int small = Math.min(city.get(j), hero.get(i));
				ans += small;
				city.set(j, city.get(j) - small);
				hero.set(i, hero.get(i) - small);
//				System.out.println(city.get(j));
//				System.out.println(hero.get(i));
			}
		}
		System.out.println(ans);
	}
}
