import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		long ans = 0;

		Scanner sc = new Scanner(System.in);
		int  n = sc.nextInt();
//		longd = sc.nextInt();
//
		boolean f = false;
		int[] array = new int [n+1];
		int[] array2 = new int[n];
		for (int i = 0; i < n+1; i++) {
			array[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			array2[i] = sc.nextInt();
		}

		long  tmp = 0;
		for (int i = 0; i < n+1; i++) {
			if(tmp > 0) {
				if(array[i]>=tmp) {
					ans = ans + tmp;
					array[i] = array[i] - (int)tmp;
				} else {
					ans = ans + array[i];
					array[i]=0;
				}
				tmp = 0;
			}
			if(i == n) {
				continue;
			}
			if(array[i] >= array2[i]) {
				ans = ans + array2[i];
				tmp = 0;
			} else {
				ans = ans + array[i];
				tmp  = (array2[i] - array[i]);
			}
//			System.out.println(ans);
		}

		System.out.println(ans);

		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		long ans = 0;

		Scanner sc = new Scanner(System.in);
		int  n = sc.nextInt();
//		longd = sc.nextInt();
//
		boolean f = false;
		int[] array = new int [n+1];
		int[] array2 = new int[n];
		for (int i = 0; i < n+1; i++) {
			array[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			array2[i] = sc.nextInt();
		}

		long  tmp = 0;
		for (int i = 0; i < n+1; i++) {
			if(tmp > 0) {
				if(array[i]>=tmp) {
					ans = ans + tmp;
					array[i] = array[i] - (int)tmp;
				} else {
					ans = ans + array[i];
					array[i]=0;
				}
				tmp = 0;
			}
			if(i == n) {
				continue;
			}
			if(array[i] >= array2[i]) {
				ans = ans + array2[i];
				tmp = 0;
			} else {
				ans = ans + array[i];
				tmp  = (array2[i] - array[i]);
			}
//			System.out.println(ans);
		}

		System.out.println(ans);

		sc.close();
	}
} Main public static void main(String[] args) {

		long ans = 0;

		Scanner sc = new Scanner(System.in);
		int  n = sc.nextInt();
//		longd = sc.nextInt();
//
		boolean f = false;
		int[] array = new int [n+1];
		int[] array2 = new int[n];
		for (int i = 0; i < n+1; i++) {
			array[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			array2[i] = sc.nextInt();
		}

		long  tmp = 0;
		for (int i = 0; i < n+1; i++) {
			if(tmp > 0) {
				if(array[i]>=tmp) {
					ans = ans + tmp;
					array[i] = array[i] - (int)tmp;
				} else {
					ans = ans + array[i];
					array[i]=0;
				}
				tmp = 0;
			}
			if(i == n) {
				continue;
			}
			if(array[i] >= array2[i]) {
				ans = ans + array2[i];
				tmp = 0;
			} else {
				ans = ans + array[i];
				tmp  = (array2[i] - array[i]);
			}
//			System.out.println(ans);
		}

		System.out.println(ans);

		sc.close();
	} main {

		long ans = 0;

		Scanner sc = new Scanner(System.in);
		int  n = sc.nextInt();
//		longd = sc.nextInt();
//
		boolean f = false;
		int[] array = new int [n+1];
		int[] array2 = new int[n];
		for (int i = 0; i < n+1; i++) {
			array[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			array2[i] = sc.nextInt();
		}

		long  tmp = 0;
		for (int i = 0; i < n+1; i++) {
			if(tmp > 0) {
				if(array[i]>=tmp) {
					ans = ans + tmp;
					array[i] = array[i] - (int)tmp;
				} else {
					ans = ans + array[i];
					array[i]=0;
				}
				tmp = 0;
			}
			if(i == n) {
				continue;
			}
			if(array[i] >= array2[i]) {
				ans = ans + array2[i];
				tmp = 0;
			} else {
				ans = ans + array[i];
				tmp  = (array2[i] - array[i]);
			}
//			System.out.println(ans);
		}

		System.out.println(ans);

		sc.close();
	} long ans = 0; ans 0 Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int  n = sc.nextInt(); n sc.nextInt() sc.nextInt sc boolean f = false; f false int[] array = new int [n+1]; array new int [n+1] n+1 n 1 int[] array2 = new int[n]; array2 new int[n] n for (int i = 0; i < n+1; i++) {
			array[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < n+1 i n+1 n 1 i++ i++ i {
			array[i] = sc.nextInt();
		} {
			array[i] = sc.nextInt();
		} array[i] = sc.nextInt() array[i] array i sc.nextInt() sc.nextInt sc for (int i = 0; i < n; i++) {
			array2[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			array2[i] = sc.nextInt();
		} {
			array2[i] = sc.nextInt();
		} array2[i] = sc.nextInt() array2[i] array2 i sc.nextInt() sc.nextInt sc long  tmp = 0; tmp 0 for (int i = 0; i < n+1; i++) {
			if(tmp > 0) {
				if(array[i]>=tmp) {
					ans = ans + tmp;
					array[i] = array[i] - (int)tmp;
				} else {
					ans = ans + array[i];
					array[i]=0;
				}
				tmp = 0;
			}
			if(i == n) {
				continue;
			}
			if(array[i] >= array2[i]) {
				ans = ans + array2[i];
				tmp = 0;
			} else {
				ans = ans + array[i];
				tmp  = (array2[i] - array[i]);
			}
//			System.out.println(ans);
		} int i = 0; int i = 0; i 0 i < n+1 i n+1 n 1 i++ i++ i {
			if(tmp > 0) {
				if(array[i]>=tmp) {
					ans = ans + tmp;
					array[i] = array[i] - (int)tmp;
				} else {
					ans = ans + array[i];
					array[i]=0;
				}
				tmp = 0;
			}
			if(i == n) {
				continue;
			}
			if(array[i] >= array2[i]) {
				ans = ans + array2[i];
				tmp = 0;
			} else {
				ans = ans + array[i];
				tmp  = (array2[i] - array[i]);
			}
//			System.out.println(ans);
		} {
			if(tmp > 0) {
				if(array[i]>=tmp) {
					ans = ans + tmp;
					array[i] = array[i] - (int)tmp;
				} else {
					ans = ans + array[i];
					array[i]=0;
				}
				tmp = 0;
			}
			if(i == n) {
				continue;
			}
			if(array[i] >= array2[i]) {
				ans = ans + array2[i];
				tmp = 0;
			} else {
				ans = ans + array[i];
				tmp  = (array2[i] - array[i]);
			}
//			System.out.println(ans);
		} if(tmp > 0) {
				if(array[i]>=tmp) {
					ans = ans + tmp;
					array[i] = array[i] - (int)tmp;
				} else {
					ans = ans + array[i];
					array[i]=0;
				}
				tmp = 0;
			} tmp > 0 tmp 0 {
				if(array[i]>=tmp) {
					ans = ans + tmp;
					array[i] = array[i] - (int)tmp;
				} else {
					ans = ans + array[i];
					array[i]=0;
				}
				tmp = 0;
			} if(array[i]>=tmp) {
					ans = ans + tmp;
					array[i] = array[i] - (int)tmp;
				} else {
					ans = ans + array[i];
					array[i]=0;
				} array[i]>=tmp array[i] array i tmp {
					ans = ans + tmp;
					array[i] = array[i] - (int)tmp;
				} ans = ans + tmp ans ans + tmp ans tmp array[i] = array[i] - (int)tmp array[i] array i array[i] - (int)tmp array[i] array i (int)tmp {
					ans = ans + array[i];
					array[i]=0;
				} ans = ans + array[i] ans ans + array[i] ans array[i] array i array[i]=0 array[i] array i 0 tmp = 0 tmp 0 if(i == n) {
				continue;
			} i == n i n {
				continue;
			} continue; if(array[i] >= array2[i]) {
				ans = ans + array2[i];
				tmp = 0;
			} else {
				ans = ans + array[i];
				tmp  = (array2[i] - array[i]);
			} array[i] >= array2[i] array[i] array i array2[i] array2 i {
				ans = ans + array2[i];
				tmp = 0;
			} ans = ans + array2[i] ans ans + array2[i] ans array2[i] array2 i tmp = 0 tmp 0 {
				ans = ans + array[i];
				tmp  = (array2[i] - array[i]);
			} ans = ans + array[i] ans ans + array[i] ans array[i] array i tmp  = (array2[i] - array[i]) tmp (array2[i] - array[i]) array2[i] array2 i array[i] array i System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {

		long ans = 0;

		Scanner sc = new Scanner(System.in);
		int  n = sc.nextInt();
//		longd = sc.nextInt();
//
		boolean f = false;
		int[] array = new int [n+1];
		int[] array2 = new int[n];
		for (int i = 0; i < n+1; i++) {
			array[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			array2[i] = sc.nextInt();
		}

		long  tmp = 0;
		for (int i = 0; i < n+1; i++) {
			if(tmp > 0) {
				if(array[i]>=tmp) {
					ans = ans + tmp;
					array[i] = array[i] - (int)tmp;
				} else {
					ans = ans + array[i];
					array[i]=0;
				}
				tmp = 0;
			}
			if(i == n) {
				continue;
			}
			if(array[i] >= array2[i]) {
				ans = ans + array2[i];
				tmp = 0;
			} else {
				ans = ans + array[i];
				tmp  = (array2[i] - array[i]);
			}
//			System.out.println(ans);
		}

		System.out.println(ans);

		sc.close();
	}
} public class Main {

	public static void main(String[] args) {

		long ans = 0;

		Scanner sc = new Scanner(System.in);
		int  n = sc.nextInt();
//		longd = sc.nextInt();
//
		boolean f = false;
		int[] array = new int [n+1];
		int[] array2 = new int[n];
		for (int i = 0; i < n+1; i++) {
			array[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			array2[i] = sc.nextInt();
		}

		long  tmp = 0;
		for (int i = 0; i < n+1; i++) {
			if(tmp > 0) {
				if(array[i]>=tmp) {
					ans = ans + tmp;
					array[i] = array[i] - (int)tmp;
				} else {
					ans = ans + array[i];
					array[i]=0;
				}
				tmp = 0;
			}
			if(i == n) {
				continue;
			}
			if(array[i] >= array2[i]) {
				ans = ans + array2[i];
				tmp = 0;
			} else {
				ans = ans + array[i];
				tmp  = (array2[i] - array[i]);
			}
//			System.out.println(ans);
		}

		System.out.println(ans);

		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		long ans = 0;

		Scanner sc = new Scanner(System.in);
		int  n = sc.nextInt();
//		longd = sc.nextInt();
//
		boolean f = false;
		int[] array = new int [n+1];
		int[] array2 = new int[n];
		for (int i = 0; i < n+1; i++) {
			array[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			array2[i] = sc.nextInt();
		}

		long  tmp = 0;
		for (int i = 0; i < n+1; i++) {
			if(tmp > 0) {
				if(array[i]>=tmp) {
					ans = ans + tmp;
					array[i] = array[i] - (int)tmp;
				} else {
					ans = ans + array[i];
					array[i]=0;
				}
				tmp = 0;
			}
			if(i == n) {
				continue;
			}
			if(array[i] >= array2[i]) {
				ans = ans + array2[i];
				tmp = 0;
			} else {
				ans = ans + array[i];
				tmp  = (array2[i] - array[i]);
			}
//			System.out.println(ans);
		}

		System.out.println(ans);

		sc.close();
	}
}