import java.util.*;

public class Main {
	void solve() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n];
		long before = 0;
		for(int i = 0; i < n + 1; i++) {
			a[i] = scan.nextInt();
			before += a[i];
		}
		for(int i = 0; i < n; i++) b[i] = scan.nextInt();
		long after = 0;
		for(int i = 0; i < n; i++) {
			if(a[i] <= b[i]) {
				b[i] -= a[i];
				a[i] = 0;
				a[i + 1] -= b[i] - a[i];
				if(a[i + 1] < 0) a[i + 1] = 0;
			} else {
				a[i] -= b[i];
				b[i] = 0;
			}
		}
		for(int i = 0; i < n + 1; i++) {
			a[i] = Math.max(a[i], 0);
			after += a[i];
		}
		System.out.println(before - after);
		scan.close();
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
} import java.util.*; util.* java public class Main {
	void solve() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n];
		long before = 0;
		for(int i = 0; i < n + 1; i++) {
			a[i] = scan.nextInt();
			before += a[i];
		}
		for(int i = 0; i < n; i++) b[i] = scan.nextInt();
		long after = 0;
		for(int i = 0; i < n; i++) {
			if(a[i] <= b[i]) {
				b[i] -= a[i];
				a[i] = 0;
				a[i + 1] -= b[i] - a[i];
				if(a[i + 1] < 0) a[i + 1] = 0;
			} else {
				a[i] -= b[i];
				b[i] = 0;
			}
		}
		for(int i = 0; i < n + 1; i++) {
			a[i] = Math.max(a[i], 0);
			after += a[i];
		}
		System.out.println(before - after);
		scan.close();
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
} Main void solve() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n];
		long before = 0;
		for(int i = 0; i < n + 1; i++) {
			a[i] = scan.nextInt();
			before += a[i];
		}
		for(int i = 0; i < n; i++) b[i] = scan.nextInt();
		long after = 0;
		for(int i = 0; i < n; i++) {
			if(a[i] <= b[i]) {
				b[i] -= a[i];
				a[i] = 0;
				a[i + 1] -= b[i] - a[i];
				if(a[i + 1] < 0) a[i + 1] = 0;
			} else {
				a[i] -= b[i];
				b[i] = 0;
			}
		}
		for(int i = 0; i < n + 1; i++) {
			a[i] = Math.max(a[i], 0);
			after += a[i];
		}
		System.out.println(before - after);
		scan.close();
	} solve {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n];
		long before = 0;
		for(int i = 0; i < n + 1; i++) {
			a[i] = scan.nextInt();
			before += a[i];
		}
		for(int i = 0; i < n; i++) b[i] = scan.nextInt();
		long after = 0;
		for(int i = 0; i < n; i++) {
			if(a[i] <= b[i]) {
				b[i] -= a[i];
				a[i] = 0;
				a[i + 1] -= b[i] - a[i];
				if(a[i + 1] < 0) a[i + 1] = 0;
			} else {
				a[i] -= b[i];
				b[i] = 0;
			}
		}
		for(int i = 0; i < n + 1; i++) {
			a[i] = Math.max(a[i], 0);
			after += a[i];
		}
		System.out.println(before - after);
		scan.close();
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan 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 long before = 0; before 0 for(int i = 0; i < n + 1; i++) {
			a[i] = scan.nextInt();
			before += a[i];
		} int i = 0; int i = 0; i 0 i < n + 1 i n + 1 n 1 i++ i++ i {
			a[i] = scan.nextInt();
			before += a[i];
		} {
			a[i] = scan.nextInt();
			before += a[i];
		} a[i] = scan.nextInt() a[i] a i scan.nextInt() scan.nextInt scan before += a[i] before a[i] a i for(int i = 0; i < n; i++) b[i] = scan.nextInt(); int i = 0; int i = 0; i 0 i < n i n i++ i++ i b[i] = scan.nextInt(); b[i] = scan.nextInt() b[i] b i scan.nextInt() scan.nextInt scan long after = 0; after 0 for(int i = 0; i < n; i++) {
			if(a[i] <= b[i]) {
				b[i] -= a[i];
				a[i] = 0;
				a[i + 1] -= b[i] - a[i];
				if(a[i + 1] < 0) a[i + 1] = 0;
			} else {
				a[i] -= b[i];
				b[i] = 0;
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			if(a[i] <= b[i]) {
				b[i] -= a[i];
				a[i] = 0;
				a[i + 1] -= b[i] - a[i];
				if(a[i + 1] < 0) a[i + 1] = 0;
			} else {
				a[i] -= b[i];
				b[i] = 0;
			}
		} {
			if(a[i] <= b[i]) {
				b[i] -= a[i];
				a[i] = 0;
				a[i + 1] -= b[i] - a[i];
				if(a[i + 1] < 0) a[i + 1] = 0;
			} else {
				a[i] -= b[i];
				b[i] = 0;
			}
		} if(a[i] <= b[i]) {
				b[i] -= a[i];
				a[i] = 0;
				a[i + 1] -= b[i] - a[i];
				if(a[i + 1] < 0) a[i + 1] = 0;
			} else {
				a[i] -= b[i];
				b[i] = 0;
			} a[i] <= b[i] a[i] a i b[i] b i {
				b[i] -= a[i];
				a[i] = 0;
				a[i + 1] -= b[i] - a[i];
				if(a[i + 1] < 0) a[i + 1] = 0;
			} b[i] -= a[i] b[i] b i a[i] a i a[i] = 0 a[i] a i 0 a[i + 1] -= b[i] - a[i] a[i + 1] a i + 1 i 1 b[i] - a[i] b[i] b i a[i] a i if(a[i + 1] < 0) a[i + 1] = 0; a[i + 1] < 0 a[i + 1] a i + 1 i 1 0 a[i + 1] = 0 a[i + 1] a i + 1 i 1 0 {
				a[i] -= b[i];
				b[i] = 0;
			} a[i] -= b[i] a[i] a i b[i] b i b[i] = 0 b[i] b i 0 for(int i = 0; i < n + 1; i++) {
			a[i] = Math.max(a[i], 0);
			after += a[i];
		} int i = 0; int i = 0; i 0 i < n + 1 i n + 1 n 1 i++ i++ i {
			a[i] = Math.max(a[i], 0);
			after += a[i];
		} {
			a[i] = Math.max(a[i], 0);
			after += a[i];
		} a[i] = Math.max(a[i], 0) a[i] a i Math.max(a[i], 0) Math.max Math a[i] a i 0 after += a[i] after a[i] a i System.out.println(before - after) System.out.println System.out System System.out before - after before after scan.close() scan.close scan public static void main(String[] args) {
		new Main().solve();
	} main {
		new Main().solve();
	} new Main().solve() new Main().solve new Main() String[] args args public class Main {
	void solve() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n];
		long before = 0;
		for(int i = 0; i < n + 1; i++) {
			a[i] = scan.nextInt();
			before += a[i];
		}
		for(int i = 0; i < n; i++) b[i] = scan.nextInt();
		long after = 0;
		for(int i = 0; i < n; i++) {
			if(a[i] <= b[i]) {
				b[i] -= a[i];
				a[i] = 0;
				a[i + 1] -= b[i] - a[i];
				if(a[i + 1] < 0) a[i + 1] = 0;
			} else {
				a[i] -= b[i];
				b[i] = 0;
			}
		}
		for(int i = 0; i < n + 1; i++) {
			a[i] = Math.max(a[i], 0);
			after += a[i];
		}
		System.out.println(before - after);
		scan.close();
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
} public class Main {
	void solve() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n];
		long before = 0;
		for(int i = 0; i < n + 1; i++) {
			a[i] = scan.nextInt();
			before += a[i];
		}
		for(int i = 0; i < n; i++) b[i] = scan.nextInt();
		long after = 0;
		for(int i = 0; i < n; i++) {
			if(a[i] <= b[i]) {
				b[i] -= a[i];
				a[i] = 0;
				a[i + 1] -= b[i] - a[i];
				if(a[i + 1] < 0) a[i + 1] = 0;
			} else {
				a[i] -= b[i];
				b[i] = 0;
			}
		}
		for(int i = 0; i < n + 1; i++) {
			a[i] = Math.max(a[i], 0);
			after += a[i];
		}
		System.out.println(before - after);
		scan.close();
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
} Main
import java.util.*;

public class Main {
	void solve() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n];
		long before = 0;
		for(int i = 0; i < n + 1; i++) {
			a[i] = scan.nextInt();
			before += a[i];
		}
		for(int i = 0; i < n; i++) b[i] = scan.nextInt();
		long after = 0;
		for(int i = 0; i < n; i++) {
			if(a[i] <= b[i]) {
				b[i] -= a[i];
				a[i] = 0;
				a[i + 1] -= b[i] - a[i];
				if(a[i + 1] < 0) a[i + 1] = 0;
			} else {
				a[i] -= b[i];
				b[i] = 0;
			}
		}
		for(int i = 0; i < n + 1; i++) {
			a[i] = Math.max(a[i], 0);
			after += a[i];
		}
		System.out.println(before - after);
		scan.close();
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}
