import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N + 1];
		int B[] = new int[N];

		long jizenSum = 0;
		for (int i = 0; i < N + 1; i++) {
			A[i] = sc.nextInt();
			jizenSum += A[i];
		}

		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}

		int tmp = 0;
		for (int i = 0; i < N; i++) {
			tmp = A[i] - B[i];
			if (tmp < 0) {
				if (B[i] - A[i] > A[i + 1]) {
					A[i + 1] = 0;
				} else {
					A[i + 1] = A[i + 1] - (B[i] - A[i]);
				}
				A[i] = 0;
			} else {
				A[i] = tmp;
			}
		}

		long sum = 0;
		for (int i = 0; i < N + 1; i++) {
			sum += A[i];
		}

		System.out.println(jizenSum - sum);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N + 1];
		int B[] = new int[N];

		long jizenSum = 0;
		for (int i = 0; i < N + 1; i++) {
			A[i] = sc.nextInt();
			jizenSum += A[i];
		}

		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}

		int tmp = 0;
		for (int i = 0; i < N; i++) {
			tmp = A[i] - B[i];
			if (tmp < 0) {
				if (B[i] - A[i] > A[i + 1]) {
					A[i + 1] = 0;
				} else {
					A[i + 1] = A[i + 1] - (B[i] - A[i]);
				}
				A[i] = 0;
			} else {
				A[i] = tmp;
			}
		}

		long sum = 0;
		for (int i = 0; i < N + 1; i++) {
			sum += A[i];
		}

		System.out.println(jizenSum - sum);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N + 1];
		int B[] = new int[N];

		long jizenSum = 0;
		for (int i = 0; i < N + 1; i++) {
			A[i] = sc.nextInt();
			jizenSum += A[i];
		}

		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}

		int tmp = 0;
		for (int i = 0; i < N; i++) {
			tmp = A[i] - B[i];
			if (tmp < 0) {
				if (B[i] - A[i] > A[i + 1]) {
					A[i + 1] = 0;
				} else {
					A[i + 1] = A[i + 1] - (B[i] - A[i]);
				}
				A[i] = 0;
			} else {
				A[i] = tmp;
			}
		}

		long sum = 0;
		for (int i = 0; i < N + 1; i++) {
			sum += A[i];
		}

		System.out.println(jizenSum - sum);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N + 1];
		int B[] = new int[N];

		long jizenSum = 0;
		for (int i = 0; i < N + 1; i++) {
			A[i] = sc.nextInt();
			jizenSum += A[i];
		}

		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}

		int tmp = 0;
		for (int i = 0; i < N; i++) {
			tmp = A[i] - B[i];
			if (tmp < 0) {
				if (B[i] - A[i] > A[i + 1]) {
					A[i + 1] = 0;
				} else {
					A[i + 1] = A[i + 1] - (B[i] - A[i]);
				}
				A[i] = 0;
			} else {
				A[i] = tmp;
			}
		}

		long sum = 0;
		for (int i = 0; i < N + 1; i++) {
			sum += A[i];
		}

		System.out.println(jizenSum - sum);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc 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 jizenSum = 0; jizenSum 0 for (int i = 0; i < N + 1; i++) {
			A[i] = sc.nextInt();
			jizenSum += A[i];
		} int i = 0; int i = 0; i 0 i < N + 1 i N + 1 N 1 i++ i++ i {
			A[i] = sc.nextInt();
			jizenSum += A[i];
		} {
			A[i] = sc.nextInt();
			jizenSum += A[i];
		} A[i] = sc.nextInt() A[i] A i sc.nextInt() sc.nextInt sc jizenSum += A[i] jizenSum A[i] A i for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			B[i] = sc.nextInt();
		} {
			B[i] = sc.nextInt();
		} B[i] = sc.nextInt() B[i] B i sc.nextInt() sc.nextInt sc int tmp = 0; tmp 0 for (int i = 0; i < N; i++) {
			tmp = A[i] - B[i];
			if (tmp < 0) {
				if (B[i] - A[i] > A[i + 1]) {
					A[i + 1] = 0;
				} else {
					A[i + 1] = A[i + 1] - (B[i] - A[i]);
				}
				A[i] = 0;
			} else {
				A[i] = tmp;
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			tmp = A[i] - B[i];
			if (tmp < 0) {
				if (B[i] - A[i] > A[i + 1]) {
					A[i + 1] = 0;
				} else {
					A[i + 1] = A[i + 1] - (B[i] - A[i]);
				}
				A[i] = 0;
			} else {
				A[i] = tmp;
			}
		} {
			tmp = A[i] - B[i];
			if (tmp < 0) {
				if (B[i] - A[i] > A[i + 1]) {
					A[i + 1] = 0;
				} else {
					A[i + 1] = A[i + 1] - (B[i] - A[i]);
				}
				A[i] = 0;
			} else {
				A[i] = tmp;
			}
		} tmp = A[i] - B[i] tmp A[i] - B[i] A[i] A i B[i] B i if (tmp < 0) {
				if (B[i] - A[i] > A[i + 1]) {
					A[i + 1] = 0;
				} else {
					A[i + 1] = A[i + 1] - (B[i] - A[i]);
				}
				A[i] = 0;
			} else {
				A[i] = tmp;
			} tmp < 0 tmp 0 {
				if (B[i] - A[i] > A[i + 1]) {
					A[i + 1] = 0;
				} else {
					A[i + 1] = A[i + 1] - (B[i] - A[i]);
				}
				A[i] = 0;
			} if (B[i] - A[i] > A[i + 1]) {
					A[i + 1] = 0;
				} else {
					A[i + 1] = A[i + 1] - (B[i] - A[i]);
				} B[i] - A[i] > A[i + 1] B[i] - A[i] B[i] B i A[i] A i A[i + 1] A i + 1 i 1 {
					A[i + 1] = 0;
				} A[i + 1] = 0 A[i + 1] A i + 1 i 1 0 {
					A[i + 1] = A[i + 1] - (B[i] - A[i]);
				} A[i + 1] = A[i + 1] - (B[i] - A[i]) A[i + 1] A i + 1 i 1 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 A[i] = 0 A[i] A i 0 {
				A[i] = tmp;
			} A[i] = tmp A[i] A i tmp long sum = 0; sum 0 for (int i = 0; i < N + 1; i++) {
			sum += A[i];
		} int i = 0; int i = 0; i 0 i < N + 1 i N + 1 N 1 i++ i++ i {
			sum += A[i];
		} {
			sum += A[i];
		} sum += A[i] sum A[i] A i System.out.println(jizenSum - sum) System.out.println System.out System System.out jizenSum - sum jizenSum sum String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N + 1];
		int B[] = new int[N];

		long jizenSum = 0;
		for (int i = 0; i < N + 1; i++) {
			A[i] = sc.nextInt();
			jizenSum += A[i];
		}

		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}

		int tmp = 0;
		for (int i = 0; i < N; i++) {
			tmp = A[i] - B[i];
			if (tmp < 0) {
				if (B[i] - A[i] > A[i + 1]) {
					A[i + 1] = 0;
				} else {
					A[i + 1] = A[i + 1] - (B[i] - A[i]);
				}
				A[i] = 0;
			} else {
				A[i] = tmp;
			}
		}

		long sum = 0;
		for (int i = 0; i < N + 1; i++) {
			sum += A[i];
		}

		System.out.println(jizenSum - sum);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N + 1];
		int B[] = new int[N];

		long jizenSum = 0;
		for (int i = 0; i < N + 1; i++) {
			A[i] = sc.nextInt();
			jizenSum += A[i];
		}

		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}

		int tmp = 0;
		for (int i = 0; i < N; i++) {
			tmp = A[i] - B[i];
			if (tmp < 0) {
				if (B[i] - A[i] > A[i + 1]) {
					A[i + 1] = 0;
				} else {
					A[i + 1] = A[i + 1] - (B[i] - A[i]);
				}
				A[i] = 0;
			} else {
				A[i] = tmp;
			}
		}

		long sum = 0;
		for (int i = 0; i < N + 1; i++) {
			sum += A[i];
		}

		System.out.println(jizenSum - sum);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N + 1];
		int B[] = new int[N];

		long jizenSum = 0;
		for (int i = 0; i < N + 1; i++) {
			A[i] = sc.nextInt();
			jizenSum += A[i];
		}

		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}

		int tmp = 0;
		for (int i = 0; i < N; i++) {
			tmp = A[i] - B[i];
			if (tmp < 0) {
				if (B[i] - A[i] > A[i + 1]) {
					A[i + 1] = 0;
				} else {
					A[i + 1] = A[i + 1] - (B[i] - A[i]);
				}
				A[i] = 0;
			} else {
				A[i] = tmp;
			}
		}

		long sum = 0;
		for (int i = 0; i < N + 1; i++) {
			sum += A[i];
		}

		System.out.println(jizenSum - sum);
	}
}
