import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n];

		long ans = 0;
		int i;
		for(i = 0; i < n + 1; i++) {
			a[i] = scan.nextInt();
			ans += a[i];
		}
		for(i = 0; i < n; i++)
			b[i] = scan.nextInt();
		for(i = n - 1; i >= 0; i--) {
			int temp = b[i];
			if(a[i + 1] >= temp) {
				a[i + 1] -= temp;
			}else {
				int temp2 = temp - a[i + 1];
				a[i + 1] = 0;
				if(a[i] >= temp2) {
					a[i] -= temp2;
				}else {
					a[i] = 0;
				}
			}
		}
		for(i = 0; i < n + 1; i++) {
			ans -= a[i];
		}
		System.out.println(ans);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n];

		long ans = 0;
		int i;
		for(i = 0; i < n + 1; i++) {
			a[i] = scan.nextInt();
			ans += a[i];
		}
		for(i = 0; i < n; i++)
			b[i] = scan.nextInt();
		for(i = n - 1; i >= 0; i--) {
			int temp = b[i];
			if(a[i + 1] >= temp) {
				a[i + 1] -= temp;
			}else {
				int temp2 = temp - a[i + 1];
				a[i + 1] = 0;
				if(a[i] >= temp2) {
					a[i] -= temp2;
				}else {
					a[i] = 0;
				}
			}
		}
		for(i = 0; i < n + 1; i++) {
			ans -= a[i];
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n];

		long ans = 0;
		int i;
		for(i = 0; i < n + 1; i++) {
			a[i] = scan.nextInt();
			ans += a[i];
		}
		for(i = 0; i < n; i++)
			b[i] = scan.nextInt();
		for(i = n - 1; i >= 0; i--) {
			int temp = b[i];
			if(a[i + 1] >= temp) {
				a[i + 1] -= temp;
			}else {
				int temp2 = temp - a[i + 1];
				a[i + 1] = 0;
				if(a[i] >= temp2) {
					a[i] -= temp2;
				}else {
					a[i] = 0;
				}
			}
		}
		for(i = 0; i < n + 1; i++) {
			ans -= a[i];
		}
		System.out.println(ans);
	} main {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n];

		long ans = 0;
		int i;
		for(i = 0; i < n + 1; i++) {
			a[i] = scan.nextInt();
			ans += a[i];
		}
		for(i = 0; i < n; i++)
			b[i] = scan.nextInt();
		for(i = n - 1; i >= 0; i--) {
			int temp = b[i];
			if(a[i + 1] >= temp) {
				a[i + 1] -= temp;
			}else {
				int temp2 = temp - a[i + 1];
				a[i + 1] = 0;
				if(a[i] >= temp2) {
					a[i] -= temp2;
				}else {
					a[i] = 0;
				}
			}
		}
		for(i = 0; i < n + 1; i++) {
			ans -= a[i];
		}
		System.out.println(ans);
	} 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 ans = 0; ans 0 int i; i for(i = 0; i < n + 1; i++) {
			a[i] = scan.nextInt();
			ans += a[i];
		} i = 0; i = 0 i 0 i < n + 1 i n + 1 n 1 i++ i++ i {
			a[i] = scan.nextInt();
			ans += a[i];
		} {
			a[i] = scan.nextInt();
			ans += a[i];
		} a[i] = scan.nextInt() a[i] a i scan.nextInt() scan.nextInt scan ans += a[i] ans a[i] a i for(i = 0; i < n; i++)
			b[i] = scan.nextInt(); i = 0; 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 for(i = n - 1; i >= 0; i--) {
			int temp = b[i];
			if(a[i + 1] >= temp) {
				a[i + 1] -= temp;
			}else {
				int temp2 = temp - a[i + 1];
				a[i + 1] = 0;
				if(a[i] >= temp2) {
					a[i] -= temp2;
				}else {
					a[i] = 0;
				}
			}
		} i = n - 1; i = n - 1 i n - 1 n 1 i >= 0 i 0 i-- i-- i {
			int temp = b[i];
			if(a[i + 1] >= temp) {
				a[i + 1] -= temp;
			}else {
				int temp2 = temp - a[i + 1];
				a[i + 1] = 0;
				if(a[i] >= temp2) {
					a[i] -= temp2;
				}else {
					a[i] = 0;
				}
			}
		} {
			int temp = b[i];
			if(a[i + 1] >= temp) {
				a[i + 1] -= temp;
			}else {
				int temp2 = temp - a[i + 1];
				a[i + 1] = 0;
				if(a[i] >= temp2) {
					a[i] -= temp2;
				}else {
					a[i] = 0;
				}
			}
		} int temp = b[i]; temp b[i] b i if(a[i + 1] >= temp) {
				a[i + 1] -= temp;
			}else {
				int temp2 = temp - a[i + 1];
				a[i + 1] = 0;
				if(a[i] >= temp2) {
					a[i] -= temp2;
				}else {
					a[i] = 0;
				}
			} a[i + 1] >= temp a[i + 1] a i + 1 i 1 temp {
				a[i + 1] -= temp;
			} a[i + 1] -= temp a[i + 1] a i + 1 i 1 temp {
				int temp2 = temp - a[i + 1];
				a[i + 1] = 0;
				if(a[i] >= temp2) {
					a[i] -= temp2;
				}else {
					a[i] = 0;
				}
			} int temp2 = temp - a[i + 1]; temp2 temp - a[i + 1] temp a[i + 1] a i + 1 i 1 a[i + 1] = 0 a[i + 1] a i + 1 i 1 0 if(a[i] >= temp2) {
					a[i] -= temp2;
				}else {
					a[i] = 0;
				} a[i] >= temp2 a[i] a i temp2 {
					a[i] -= temp2;
				} a[i] -= temp2 a[i] a i temp2 {
					a[i] = 0;
				} a[i] = 0 a[i] a i 0 for(i = 0; i < n + 1; i++) {
			ans -= a[i];
		} i = 0; i = 0 i 0 i < n + 1 i n + 1 n 1 i++ i++ i {
			ans -= a[i];
		} {
			ans -= a[i];
		} ans -= a[i] ans a[i] a i 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) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n];

		long ans = 0;
		int i;
		for(i = 0; i < n + 1; i++) {
			a[i] = scan.nextInt();
			ans += a[i];
		}
		for(i = 0; i < n; i++)
			b[i] = scan.nextInt();
		for(i = n - 1; i >= 0; i--) {
			int temp = b[i];
			if(a[i + 1] >= temp) {
				a[i + 1] -= temp;
			}else {
				int temp2 = temp - a[i + 1];
				a[i + 1] = 0;
				if(a[i] >= temp2) {
					a[i] -= temp2;
				}else {
					a[i] = 0;
				}
			}
		}
		for(i = 0; i < n + 1; i++) {
			ans -= a[i];
		}
		System.out.println(ans);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n];

		long ans = 0;
		int i;
		for(i = 0; i < n + 1; i++) {
			a[i] = scan.nextInt();
			ans += a[i];
		}
		for(i = 0; i < n; i++)
			b[i] = scan.nextInt();
		for(i = n - 1; i >= 0; i--) {
			int temp = b[i];
			if(a[i + 1] >= temp) {
				a[i + 1] -= temp;
			}else {
				int temp2 = temp - a[i + 1];
				a[i + 1] = 0;
				if(a[i] >= temp2) {
					a[i] -= temp2;
				}else {
					a[i] = 0;
				}
			}
		}
		for(i = 0; i < n + 1; i++) {
			ans -= a[i];
		}
		System.out.println(ans);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n];

		long ans = 0;
		int i;
		for(i = 0; i < n + 1; i++) {
			a[i] = scan.nextInt();
			ans += a[i];
		}
		for(i = 0; i < n; i++)
			b[i] = scan.nextInt();
		for(i = n - 1; i >= 0; i--) {
			int temp = b[i];
			if(a[i + 1] >= temp) {
				a[i + 1] -= temp;
			}else {
				int temp2 = temp - a[i + 1];
				a[i + 1] = 0;
				if(a[i] >= temp2) {
					a[i] -= temp2;
				}else {
					a[i] = 0;
				}
			}
		}
		for(i = 0; i < n + 1; i++) {
			ans -= a[i];
		}
		System.out.println(ans);
	}
}