import java.util.Scanner;

//AtCoder Beginner Contest 135
//C	City Savers
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt((sc.next()));
		long[] aArr = new long[N + 1];
		for (int i = 0; i <= N; i++) {
			aArr[i] = Long.parseLong(sc.next());
		}
		long[] bArr = new long[N];
		for (int i = 0; i < N; i++) {
			bArr[i] = Long.parseLong(sc.next());
		}
		sc.close();

		long ans = 0;
		for (int i = N - 1; i >= 0; i--) {
			long beated = Math.min(aArr[i + 1], bArr[i]);
			ans += beated;
			aArr[i + 1] -= beated;
			bArr[i] -= beated;
			beated = Math.min(aArr[i], bArr[i]);
			ans += beated;
			aArr[i] -= beated;
		}
		System.out.println(ans);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt((sc.next()));
		long[] aArr = new long[N + 1];
		for (int i = 0; i <= N; i++) {
			aArr[i] = Long.parseLong(sc.next());
		}
		long[] bArr = new long[N];
		for (int i = 0; i < N; i++) {
			bArr[i] = Long.parseLong(sc.next());
		}
		sc.close();

		long ans = 0;
		for (int i = N - 1; i >= 0; i--) {
			long beated = Math.min(aArr[i + 1], bArr[i]);
			ans += beated;
			aArr[i + 1] -= beated;
			bArr[i] -= beated;
			beated = Math.min(aArr[i], bArr[i]);
			ans += beated;
			aArr[i] -= beated;
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt((sc.next()));
		long[] aArr = new long[N + 1];
		for (int i = 0; i <= N; i++) {
			aArr[i] = Long.parseLong(sc.next());
		}
		long[] bArr = new long[N];
		for (int i = 0; i < N; i++) {
			bArr[i] = Long.parseLong(sc.next());
		}
		sc.close();

		long ans = 0;
		for (int i = N - 1; i >= 0; i--) {
			long beated = Math.min(aArr[i + 1], bArr[i]);
			ans += beated;
			aArr[i + 1] -= beated;
			bArr[i] -= beated;
			beated = Math.min(aArr[i], bArr[i]);
			ans += beated;
			aArr[i] -= beated;
		}
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt((sc.next()));
		long[] aArr = new long[N + 1];
		for (int i = 0; i <= N; i++) {
			aArr[i] = Long.parseLong(sc.next());
		}
		long[] bArr = new long[N];
		for (int i = 0; i < N; i++) {
			bArr[i] = Long.parseLong(sc.next());
		}
		sc.close();

		long ans = 0;
		for (int i = N - 1; i >= 0; i--) {
			long beated = Math.min(aArr[i + 1], bArr[i]);
			ans += beated;
			aArr[i + 1] -= beated;
			bArr[i] -= beated;
			beated = Math.min(aArr[i], bArr[i]);
			ans += beated;
			aArr[i] -= beated;
		}
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt((sc.next())); N Integer.parseInt((sc.next())) Integer.parseInt Integer (sc.next()) sc.next sc long[] aArr = new long[N + 1]; aArr new long[N + 1] N + 1 N 1 for (int i = 0; i <= N; i++) {
			aArr[i] = Long.parseLong(sc.next());
		} int i = 0; int i = 0; i 0 i <= N i N i++ i++ i {
			aArr[i] = Long.parseLong(sc.next());
		} {
			aArr[i] = Long.parseLong(sc.next());
		} aArr[i] = Long.parseLong(sc.next()) aArr[i] aArr i Long.parseLong(sc.next()) Long.parseLong Long sc.next() sc.next sc long[] bArr = new long[N]; bArr new long[N] N for (int i = 0; i < N; i++) {
			bArr[i] = Long.parseLong(sc.next());
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			bArr[i] = Long.parseLong(sc.next());
		} {
			bArr[i] = Long.parseLong(sc.next());
		} bArr[i] = Long.parseLong(sc.next()) bArr[i] bArr i Long.parseLong(sc.next()) Long.parseLong Long sc.next() sc.next sc sc.close() sc.close sc long ans = 0; ans 0 for (int i = N - 1; i >= 0; i--) {
			long beated = Math.min(aArr[i + 1], bArr[i]);
			ans += beated;
			aArr[i + 1] -= beated;
			bArr[i] -= beated;
			beated = Math.min(aArr[i], bArr[i]);
			ans += beated;
			aArr[i] -= beated;
		} int i = N - 1; int i = N - 1; i N - 1 N 1 i >= 0 i 0 i-- i-- i {
			long beated = Math.min(aArr[i + 1], bArr[i]);
			ans += beated;
			aArr[i + 1] -= beated;
			bArr[i] -= beated;
			beated = Math.min(aArr[i], bArr[i]);
			ans += beated;
			aArr[i] -= beated;
		} {
			long beated = Math.min(aArr[i + 1], bArr[i]);
			ans += beated;
			aArr[i + 1] -= beated;
			bArr[i] -= beated;
			beated = Math.min(aArr[i], bArr[i]);
			ans += beated;
			aArr[i] -= beated;
		} long beated = Math.min(aArr[i + 1], bArr[i]); beated Math.min(aArr[i + 1], bArr[i]) Math.min Math aArr[i + 1] aArr i + 1 i 1 bArr[i] bArr i ans += beated ans beated aArr[i + 1] -= beated aArr[i + 1] aArr i + 1 i 1 beated bArr[i] -= beated bArr[i] bArr i beated beated = Math.min(aArr[i], bArr[i]) beated Math.min(aArr[i], bArr[i]) Math.min Math aArr[i] aArr i bArr[i] bArr i ans += beated ans beated aArr[i] -= beated aArr[i] aArr i beated 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 sc = new Scanner(System.in);
		int N = Integer.parseInt((sc.next()));
		long[] aArr = new long[N + 1];
		for (int i = 0; i <= N; i++) {
			aArr[i] = Long.parseLong(sc.next());
		}
		long[] bArr = new long[N];
		for (int i = 0; i < N; i++) {
			bArr[i] = Long.parseLong(sc.next());
		}
		sc.close();

		long ans = 0;
		for (int i = N - 1; i >= 0; i--) {
			long beated = Math.min(aArr[i + 1], bArr[i]);
			ans += beated;
			aArr[i + 1] -= beated;
			bArr[i] -= beated;
			beated = Math.min(aArr[i], bArr[i]);
			ans += beated;
			aArr[i] -= beated;
		}
		System.out.println(ans);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt((sc.next()));
		long[] aArr = new long[N + 1];
		for (int i = 0; i <= N; i++) {
			aArr[i] = Long.parseLong(sc.next());
		}
		long[] bArr = new long[N];
		for (int i = 0; i < N; i++) {
			bArr[i] = Long.parseLong(sc.next());
		}
		sc.close();

		long ans = 0;
		for (int i = N - 1; i >= 0; i--) {
			long beated = Math.min(aArr[i + 1], bArr[i]);
			ans += beated;
			aArr[i + 1] -= beated;
			bArr[i] -= beated;
			beated = Math.min(aArr[i], bArr[i]);
			ans += beated;
			aArr[i] -= beated;
		}
		System.out.println(ans);
	}
} Main
import java.util.Scanner;

//AtCoder Beginner Contest 135
//C	City Savers
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt((sc.next()));
		long[] aArr = new long[N + 1];
		for (int i = 0; i <= N; i++) {
			aArr[i] = Long.parseLong(sc.next());
		}
		long[] bArr = new long[N];
		for (int i = 0; i < N; i++) {
			bArr[i] = Long.parseLong(sc.next());
		}
		sc.close();

		long ans = 0;
		for (int i = N - 1; i >= 0; i--) {
			long beated = Math.min(aArr[i + 1], bArr[i]);
			ans += beated;
			aArr[i + 1] -= beated;
			bArr[i] -= beated;
			beated = Math.min(aArr[i], bArr[i]);
			ans += beated;
			aArr[i] -= beated;
		}
		System.out.println(ans);
	}
}
