#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map> 
using namespace std;

#define LL long long
#define MOD (1000000007)

//�ő����
LL GCD(LL a, LL b) {
	if (a < b) {
		LL temp = a;
		a = b;
		b = temp;
	}

	LL r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

//�ŏ����{��
LL LCM(LL a, LL b) {
	return a * b / GCD(a, b);
}


//135
int main() {
	LL N;

	scanf("%lld", &N);

	vector<LL> A;
	for (int i = 0; i < N + 1; i++) {
		LL val;
		scanf("%lld", &val);
		A.push_back(val);
	}

	LL result = 0;

	for (int i = 0; i < N; i++) {
		LL val;
		scanf("%lld", &val);
		
		if (val <= A[i]) {
			A[i] -= val;
			result += val;
		}
		else {
			LL last = val - A[i];
			result += A[i];
			A[i] = 0;

			if (last < A[i + 1]) {
				result += last;
				A[i + 1] -= last;
			}
			else {
				result += A[i + 1];
				A[i + 1] = 0;
			}
		}
	}

	printf("%lld\n", result);

	return 0;
}

//134
/*
int main() {
	LL N;

	scanf("%lld", &N);

	vector<LL> v;

	LL max = 0;
	LL max_index = 0;
	LL sec_max = 0;
	for (int i = 0; i < N; i++) {
		LL val;
		scanf("%lld", &val);
		v.push_back(val);

		if (val > max) {
			sec_max = max;
			max = val;
			max_index = i;
		}
		else if (val > sec_max) {
			sec_max = val;
		}
	}

	for (int i = 0; i < N; i++) {
		if (i == max_index) {
			printf("%lld\n", sec_max);
		}
		else {
			printf("%lld\n", max);
		}
	}

	return 0;
}
*/

//133
/*
int main() {
	LL L, R;

	scanf("%lld %lld", &L, &R);

	LL a = L % 2019;

	LL result = 0;
	if (a == 0) {
		result = 0;
	}
	else if(a + (R - L) >= 2019) {
		result = 0;
	}
	else {
		result = 100000000LL;
		for (LL i = a; i < a + (R - L); i++) {
			for (LL j = i + 1; j <= a + (R - L); j++) {
				LL val = (i * j) % 2019;
				result = std::min(result, val);
			}
		}
	}

	printf("%lld\n", result);

	return 0;
}
*/

//132
/*
int main() {
	LL N;

	scanf("%lld", &N);

	vector<LL> v;

	for (int i = 0; i < N; i++) {
		LL d;
		scanf("%lld", &d);

		v.push_back(d);
	}

	std::sort(v.begin(), v.end());

	printf("%lld\n", v[N / 2] - v[N / 2 - 1]);

	return 0;
}
*/

//131
/*
int main() {
	LL A, B, C, D;

	scanf("%lld %lld %lld %lld", &A, &B, &C, &D);

	LL result = 0;

	LL lcm = LCM(C, D);

	A -= 1;

	result += B - (B / C) - (B / D) + (B / lcm);
	result -= A - (A / C) - (A / D) + (A / lcm);

	printf("%lld\n", result);

	return 0;
}
*/

//130
/*
int main() {
	LL W, H, x, y;

	scanf("%lld %lld", &W, &H);
	scanf("%lld %lld", &x, &y);

	double result = 1.0 * W * H / 2.0;

	int sub = 0;

	if (x * 2 == W && y * 2 == H) {
		sub = 1;
	}

	printf("%0.6f %d\n", result, sub);

	return 0;
}
*/

//129
/*
int main() {
	LL N, M;

	scanf("%lld %lld", &N, &M);

	static LL dp[100010];
	memset(dp, 0, sizeof(dp));

	for (int i = 0; i < M; i++) {
		LL a;
		scanf("%lld", &a);

		dp[a] = -1;
	}

	dp[0] = 1;
	for (int i = 1; i <= N; i++) {
		if (dp[i] < 0) {
			continue;
		}

		if (dp[i - 1] > 0) {
			dp[i] += dp[i - 1]; //1step
		}
		
		if (i > 1 && dp[i - 2] > 0) {
			dp[i] += dp[i - 2]; //2step
		}

		dp[i] = dp[i] % MOD;
	}

	printf("%lld\n", dp[N]);

}
*/

//128
/*
int main() {
	LL N, M;

	scanf("%lld %lld", &N, &M);

	unsigned int relation[11]; //index->switch No.
	memset(relation, 0, sizeof(relation));

	for (int i = 1; i <= M; i++) {
		LL k;
		scanf("%lld", &k);

		for (int j = 1; j <= k; j++) {
			unsigned int s;
			scanf("%d", &s);

			relation[s] |= (1 << (i - 1));
		}
	}

	unsigned int P = 0;
	for (int i = 1; i <= M; i++) {
		unsigned p;
		scanf("%d", &p);

		if (p > 0) {
			P |= (1 << (i - 1));
		}
	}

	LL result = 0;

	for (unsigned int pattern = 0; pattern < (unsigned int)pow(2, N); pattern++) {
		unsigned int on_off = 0; //bit��0�Ȃ�_��

		for (int i = 1; i <= N; i++) {
			if (((1 << (i - 1)) & pattern) != 0) {
				on_off ^= relation[i];
			}
		}

		on_off ^= P;

		if (on_off == 0) {
			result++;
		}
	}

	printf("%lld\n", result);

}
*/

//127
/*
int main() {
	LL N, M;

	scanf("%lld %lld", &N, &M);

	LL pass_count[100010];
	memset(pass_count, 0, sizeof(pass_count));

	for (int i = 1; i <= M; i++) {
		LL L, R;

		scanf("%lld %lld", &L, &R);

		pass_count[L]++;
		pass_count[R + 1]--;
	}

	LL result = 0;
	for (int i = 1; i <= N; i++) {
		pass_count[i] += pass_count[i - 1];
		if (pass_count[i] == M) {
			result++;
		}
	}

	printf("%lld\n", result);

	return 0;
}
*/


//126
/*
int main() {
	LL N, K;

	cin >> N >> K;

	static double dp[200100];
	memset(dp, 0, sizeof(dp));

	for (int i = 1; i <= N; i++) {
		dp[i] = 1.0 / (double)N;
	}

	for (LL i = 1; i < K; i++) {
		dp[i * 2] += dp[i] * 0.5;
	}

	double result = 0;

	for (LL i = K; i < 200100; i++) {
		result += dp[i];
	}

	printf("%0.11f\n", result);

	return 0;
}
*/

Measured memory_bytes: 1400