import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] A = new long[n + 1];
		long[] B = new long[n];
		for (int i = 0; i < A.length; i++) {
			A[i] = sc.nextLong();
		}
		for (int i = 0; i < B.length; i++) {
			B[i] = sc.nextLong();
		}
		long ans = 0;
		for (int i = 0; i < B.length; i++) {
			if (B[i] > A[i]) {
				ans += A[i];
				long diff = B[i] - A[i];
				if (diff > A[i + 1]) {
					ans += A[i + 1];
					A[i + 1] = 0;
				} else {
					A[i + 1] -= diff;
					ans += diff;
				}

			} else {
				ans += B[i];
			}
		}
		System.out.println(ans);
		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] A = new long[n + 1];
		long[] B = new long[n];
		for (int i = 0; i < A.length; i++) {
			A[i] = sc.nextLong();
		}
		for (int i = 0; i < B.length; i++) {
			B[i] = sc.nextLong();
		}
		long ans = 0;
		for (int i = 0; i < B.length; i++) {
			if (B[i] > A[i]) {
				ans += A[i];
				long diff = B[i] - A[i];
				if (diff > A[i + 1]) {
					ans += A[i + 1];
					A[i + 1] = 0;
				} else {
					A[i + 1] -= diff;
					ans += diff;
				}

			} else {
				ans += B[i];
			}
		}
		System.out.println(ans);
		sc.close();
	}
} Main public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] A = new long[n + 1];
		long[] B = new long[n];
		for (int i = 0; i < A.length; i++) {
			A[i] = sc.nextLong();
		}
		for (int i = 0; i < B.length; i++) {
			B[i] = sc.nextLong();
		}
		long ans = 0;
		for (int i = 0; i < B.length; i++) {
			if (B[i] > A[i]) {
				ans += A[i];
				long diff = B[i] - A[i];
				if (diff > A[i + 1]) {
					ans += A[i + 1];
					A[i + 1] = 0;
				} else {
					A[i + 1] -= diff;
					ans += diff;
				}

			} else {
				ans += B[i];
			}
		}
		System.out.println(ans);
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] A = new long[n + 1];
		long[] B = new long[n];
		for (int i = 0; i < A.length; i++) {
			A[i] = sc.nextLong();
		}
		for (int i = 0; i < B.length; i++) {
			B[i] = sc.nextLong();
		}
		long ans = 0;
		for (int i = 0; i < B.length; i++) {
			if (B[i] > A[i]) {
				ans += A[i];
				long diff = B[i] - A[i];
				if (diff > A[i + 1]) {
					ans += A[i + 1];
					A[i + 1] = 0;
				} else {
					A[i + 1] -= diff;
					ans += diff;
				}

			} else {
				ans += B[i];
			}
		}
		System.out.println(ans);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc long[] A = new long[n + 1]; A new long[n + 1] n + 1 n 1 long[] B = new long[n]; B new long[n] n for (int i = 0; i < A.length; i++) {
			A[i] = sc.nextLong();
		} int i = 0; int i = 0; i 0 i < A.length i A.length A A.length i++ i++ i {
			A[i] = sc.nextLong();
		} {
			A[i] = sc.nextLong();
		} A[i] = sc.nextLong() A[i] A i sc.nextLong() sc.nextLong sc for (int i = 0; i < B.length; i++) {
			B[i] = sc.nextLong();
		} int i = 0; int i = 0; i 0 i < B.length i B.length B B.length i++ i++ i {
			B[i] = sc.nextLong();
		} {
			B[i] = sc.nextLong();
		} B[i] = sc.nextLong() B[i] B i sc.nextLong() sc.nextLong sc long ans = 0; ans 0 for (int i = 0; i < B.length; i++) {
			if (B[i] > A[i]) {
				ans += A[i];
				long diff = B[i] - A[i];
				if (diff > A[i + 1]) {
					ans += A[i + 1];
					A[i + 1] = 0;
				} else {
					A[i + 1] -= diff;
					ans += diff;
				}

			} else {
				ans += B[i];
			}
		} int i = 0; int i = 0; i 0 i < B.length i B.length B B.length i++ i++ i {
			if (B[i] > A[i]) {
				ans += A[i];
				long diff = B[i] - A[i];
				if (diff > A[i + 1]) {
					ans += A[i + 1];
					A[i + 1] = 0;
				} else {
					A[i + 1] -= diff;
					ans += diff;
				}

			} else {
				ans += B[i];
			}
		} {
			if (B[i] > A[i]) {
				ans += A[i];
				long diff = B[i] - A[i];
				if (diff > A[i + 1]) {
					ans += A[i + 1];
					A[i + 1] = 0;
				} else {
					A[i + 1] -= diff;
					ans += diff;
				}

			} else {
				ans += B[i];
			}
		} if (B[i] > A[i]) {
				ans += A[i];
				long diff = B[i] - A[i];
				if (diff > A[i + 1]) {
					ans += A[i + 1];
					A[i + 1] = 0;
				} else {
					A[i + 1] -= diff;
					ans += diff;
				}

			} else {
				ans += B[i];
			} B[i] > A[i] B[i] B i A[i] A i {
				ans += A[i];
				long diff = B[i] - A[i];
				if (diff > A[i + 1]) {
					ans += A[i + 1];
					A[i + 1] = 0;
				} else {
					A[i + 1] -= diff;
					ans += diff;
				}

			} ans += A[i] ans A[i] A i long diff = B[i] - A[i]; diff B[i] - A[i] B[i] B i A[i] A i if (diff > A[i + 1]) {
					ans += A[i + 1];
					A[i + 1] = 0;
				} else {
					A[i + 1] -= diff;
					ans += diff;
				} diff > A[i + 1] diff A[i + 1] A i + 1 i 1 {
					ans += A[i + 1];
					A[i + 1] = 0;
				} ans += A[i + 1] ans A[i + 1] A i + 1 i 1 A[i + 1] = 0 A[i + 1] A i + 1 i 1 0 {
					A[i + 1] -= diff;
					ans += diff;
				} A[i + 1] -= diff A[i + 1] A i + 1 i 1 diff ans += diff ans diff {
				ans += B[i];
			} ans += B[i] ans B[i] B 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) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] A = new long[n + 1];
		long[] B = new long[n];
		for (int i = 0; i < A.length; i++) {
			A[i] = sc.nextLong();
		}
		for (int i = 0; i < B.length; i++) {
			B[i] = sc.nextLong();
		}
		long ans = 0;
		for (int i = 0; i < B.length; i++) {
			if (B[i] > A[i]) {
				ans += A[i];
				long diff = B[i] - A[i];
				if (diff > A[i + 1]) {
					ans += A[i + 1];
					A[i + 1] = 0;
				} else {
					A[i + 1] -= diff;
					ans += diff;
				}

			} else {
				ans += B[i];
			}
		}
		System.out.println(ans);
		sc.close();
	}
} public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] A = new long[n + 1];
		long[] B = new long[n];
		for (int i = 0; i < A.length; i++) {
			A[i] = sc.nextLong();
		}
		for (int i = 0; i < B.length; i++) {
			B[i] = sc.nextLong();
		}
		long ans = 0;
		for (int i = 0; i < B.length; i++) {
			if (B[i] > A[i]) {
				ans += A[i];
				long diff = B[i] - A[i];
				if (diff > A[i + 1]) {
					ans += A[i + 1];
					A[i + 1] = 0;
				} else {
					A[i + 1] -= diff;
					ans += diff;
				}

			} else {
				ans += B[i];
			}
		}
		System.out.println(ans);
		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] A = new long[n + 1];
		long[] B = new long[n];
		for (int i = 0; i < A.length; i++) {
			A[i] = sc.nextLong();
		}
		for (int i = 0; i < B.length; i++) {
			B[i] = sc.nextLong();
		}
		long ans = 0;
		for (int i = 0; i < B.length; i++) {
			if (B[i] > A[i]) {
				ans += A[i];
				long diff = B[i] - A[i];
				if (diff > A[i + 1]) {
					ans += A[i + 1];
					A[i + 1] = 0;
				} else {
					A[i + 1] -= diff;
					ans += diff;
				}

			} else {
				ans += B[i];
			}
		}
		System.out.println(ans);
		sc.close();
	}
}