import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		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 < N+1; i++) {
			a[i] =sc.nextLong();
		}
		for (int i = 0; i < N; i++) {
			b[i] = sc.nextLong();
		}

		long cnt = 0;
		for (int i = 0; i < N; i++) {
			if (a[i] <= b[i]) {
				cnt += a[i];

				if (a[i+1] >= ( b[i] - a[i])) {
					cnt += (b[i] - a[i]);
					a[i+1] = a[i+1] - ( b[i] - a[i]);
				} else {
					cnt += a[i+1];
					a[i+1] = 0;
				}
			} else {
				cnt += b[i];
			}
		}
		System.out.println(cnt);
	}
} 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();
		long a[] = new long[N+1];
		long b[] = new long[N];

		for (int i = 0; i < N+1; i++) {
			a[i] =sc.nextLong();
		}
		for (int i = 0; i < N; i++) {
			b[i] = sc.nextLong();
		}

		long cnt = 0;
		for (int i = 0; i < N; i++) {
			if (a[i] <= b[i]) {
				cnt += a[i];

				if (a[i+1] >= ( b[i] - a[i])) {
					cnt += (b[i] - a[i]);
					a[i+1] = a[i+1] - ( b[i] - a[i]);
				} else {
					cnt += a[i+1];
					a[i+1] = 0;
				}
			} else {
				cnt += b[i];
			}
		}
		System.out.println(cnt);
	}
} Main public static void main(String[] args) {
		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 < N+1; i++) {
			a[i] =sc.nextLong();
		}
		for (int i = 0; i < N; i++) {
			b[i] = sc.nextLong();
		}

		long cnt = 0;
		for (int i = 0; i < N; i++) {
			if (a[i] <= b[i]) {
				cnt += a[i];

				if (a[i+1] >= ( b[i] - a[i])) {
					cnt += (b[i] - a[i]);
					a[i+1] = a[i+1] - ( b[i] - a[i]);
				} else {
					cnt += a[i+1];
					a[i+1] = 0;
				}
			} else {
				cnt += b[i];
			}
		}
		System.out.println(cnt);
	} 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 < N+1; i++) {
			a[i] =sc.nextLong();
		}
		for (int i = 0; i < N; i++) {
			b[i] = sc.nextLong();
		}

		long cnt = 0;
		for (int i = 0; i < N; i++) {
			if (a[i] <= b[i]) {
				cnt += a[i];

				if (a[i+1] >= ( b[i] - a[i])) {
					cnt += (b[i] - a[i]);
					a[i+1] = a[i+1] - ( b[i] - a[i]);
				} else {
					cnt += a[i+1];
					a[i+1] = 0;
				}
			} else {
				cnt += b[i];
			}
		}
		System.out.println(cnt);
	} 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 < N+1; i++) {
			a[i] =sc.nextLong();
		} int i = 0; int i = 0; i 0 i < N+1 i N+1 N 1 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 < N; i++) {
			b[i] = sc.nextLong();
		} int i = 0; int i = 0; i 0 i < N i N 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 cnt = 0; cnt 0 for (int i = 0; i < N; i++) {
			if (a[i] <= b[i]) {
				cnt += a[i];

				if (a[i+1] >= ( b[i] - a[i])) {
					cnt += (b[i] - a[i]);
					a[i+1] = a[i+1] - ( b[i] - a[i]);
				} else {
					cnt += a[i+1];
					a[i+1] = 0;
				}
			} else {
				cnt += b[i];
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			if (a[i] <= b[i]) {
				cnt += a[i];

				if (a[i+1] >= ( b[i] - a[i])) {
					cnt += (b[i] - a[i]);
					a[i+1] = a[i+1] - ( b[i] - a[i]);
				} else {
					cnt += a[i+1];
					a[i+1] = 0;
				}
			} else {
				cnt += b[i];
			}
		} {
			if (a[i] <= b[i]) {
				cnt += a[i];

				if (a[i+1] >= ( b[i] - a[i])) {
					cnt += (b[i] - a[i]);
					a[i+1] = a[i+1] - ( b[i] - a[i]);
				} else {
					cnt += a[i+1];
					a[i+1] = 0;
				}
			} else {
				cnt += b[i];
			}
		} if (a[i] <= b[i]) {
				cnt += a[i];

				if (a[i+1] >= ( b[i] - a[i])) {
					cnt += (b[i] - a[i]);
					a[i+1] = a[i+1] - ( b[i] - a[i]);
				} else {
					cnt += a[i+1];
					a[i+1] = 0;
				}
			} else {
				cnt += b[i];
			} a[i] <= b[i] a[i] a i b[i] b i {
				cnt += a[i];

				if (a[i+1] >= ( b[i] - a[i])) {
					cnt += (b[i] - a[i]);
					a[i+1] = a[i+1] - ( b[i] - a[i]);
				} else {
					cnt += a[i+1];
					a[i+1] = 0;
				}
			} cnt += a[i] cnt a[i] a i if (a[i+1] >= ( b[i] - a[i])) {
					cnt += (b[i] - a[i]);
					a[i+1] = a[i+1] - ( b[i] - a[i]);
				} else {
					cnt += a[i+1];
					a[i+1] = 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 {
					cnt += (b[i] - a[i]);
					a[i+1] = a[i+1] - ( b[i] - a[i]);
				} cnt += (b[i] - a[i]) cnt (b[i] - a[i]) b[i] b i a[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 {
					cnt += a[i+1];
					a[i+1] = 0;
				} cnt += a[i+1] cnt a[i+1] a i+1 i 1 a[i+1] = 0 a[i+1] a i+1 i 1 0 {
				cnt += b[i];
			} cnt += b[i] cnt b[i] b i System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {
	public static void main(String[] args) {
		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 < N+1; i++) {
			a[i] =sc.nextLong();
		}
		for (int i = 0; i < N; i++) {
			b[i] = sc.nextLong();
		}

		long cnt = 0;
		for (int i = 0; i < N; i++) {
			if (a[i] <= b[i]) {
				cnt += a[i];

				if (a[i+1] >= ( b[i] - a[i])) {
					cnt += (b[i] - a[i]);
					a[i+1] = a[i+1] - ( b[i] - a[i]);
				} else {
					cnt += a[i+1];
					a[i+1] = 0;
				}
			} else {
				cnt += b[i];
			}
		}
		System.out.println(cnt);
	}
} public class Main {
	public static void main(String[] args) {
		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 < N+1; i++) {
			a[i] =sc.nextLong();
		}
		for (int i = 0; i < N; i++) {
			b[i] = sc.nextLong();
		}

		long cnt = 0;
		for (int i = 0; i < N; i++) {
			if (a[i] <= b[i]) {
				cnt += a[i];

				if (a[i+1] >= ( b[i] - a[i])) {
					cnt += (b[i] - a[i]);
					a[i+1] = a[i+1] - ( b[i] - a[i]);
				} else {
					cnt += a[i+1];
					a[i+1] = 0;
				}
			} else {
				cnt += b[i];
			}
		}
		System.out.println(cnt);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		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 < N+1; i++) {
			a[i] =sc.nextLong();
		}
		for (int i = 0; i < N; i++) {
			b[i] = sc.nextLong();
		}

		long cnt = 0;
		for (int i = 0; i < N; i++) {
			if (a[i] <= b[i]) {
				cnt += a[i];

				if (a[i+1] >= ( b[i] - a[i])) {
					cnt += (b[i] - a[i]);
					a[i+1] = a[i+1] - ( b[i] - a[i]);
				} else {
					cnt += a[i+1];
					a[i+1] = 0;
				}
			} else {
				cnt += b[i];
			}
		}
		System.out.println(cnt);
	}
}
