import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long ans = 0;
		long[] A = new long[N+1];
		for(int i = 0; i <= N; i++)
			A[i] = sc.nextInt();
		long[] B = new long[N];
		for(int i = 0; i < N; i++)
			B[i] = sc.nextInt();
		ans += Math.min(A[0], B[0]);
		B[0] = Math.max(B[0] - A[0], 0);
		ans += Math.min(A[N], B[N-1]);
		B[N-1] = Math.max(B[N-1] - A[N], 0);
		for(int i = 1; i < N; i++) {
			ans += Math.min(A[i], B[i-1]);
			A[i] = Math.max(A[i] - B[i-1], 0);
			ans += Math.min(A[i], B[i]);
			B[i] = Math.max(B[i] - A[i], 0);
		}
		System.out.println(ans);

	}

} import java.util.*; util.* java public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long ans = 0;
		long[] A = new long[N+1];
		for(int i = 0; i <= N; i++)
			A[i] = sc.nextInt();
		long[] B = new long[N];
		for(int i = 0; i < N; i++)
			B[i] = sc.nextInt();
		ans += Math.min(A[0], B[0]);
		B[0] = Math.max(B[0] - A[0], 0);
		ans += Math.min(A[N], B[N-1]);
		B[N-1] = Math.max(B[N-1] - A[N], 0);
		for(int i = 1; i < N; i++) {
			ans += Math.min(A[i], B[i-1]);
			A[i] = Math.max(A[i] - B[i-1], 0);
			ans += Math.min(A[i], B[i]);
			B[i] = Math.max(B[i] - A[i], 0);
		}
		System.out.println(ans);

	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long ans = 0;
		long[] A = new long[N+1];
		for(int i = 0; i <= N; i++)
			A[i] = sc.nextInt();
		long[] B = new long[N];
		for(int i = 0; i < N; i++)
			B[i] = sc.nextInt();
		ans += Math.min(A[0], B[0]);
		B[0] = Math.max(B[0] - A[0], 0);
		ans += Math.min(A[N], B[N-1]);
		B[N-1] = Math.max(B[N-1] - A[N], 0);
		for(int i = 1; i < N; i++) {
			ans += Math.min(A[i], B[i-1]);
			A[i] = Math.max(A[i] - B[i-1], 0);
			ans += Math.min(A[i], B[i]);
			B[i] = Math.max(B[i] - A[i], 0);
		}
		System.out.println(ans);

	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long ans = 0;
		long[] A = new long[N+1];
		for(int i = 0; i <= N; i++)
			A[i] = sc.nextInt();
		long[] B = new long[N];
		for(int i = 0; i < N; i++)
			B[i] = sc.nextInt();
		ans += Math.min(A[0], B[0]);
		B[0] = Math.max(B[0] - A[0], 0);
		ans += Math.min(A[N], B[N-1]);
		B[N-1] = Math.max(B[N-1] - A[N], 0);
		for(int i = 1; i < N; i++) {
			ans += Math.min(A[i], B[i-1]);
			A[i] = Math.max(A[i] - B[i-1], 0);
			ans += Math.min(A[i], B[i]);
			B[i] = Math.max(B[i] - A[i], 0);
		}
		System.out.println(ans);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc long ans = 0; ans 0 long[] A = new long[N+1]; A new long[N+1] N+1 N 1 for(int i = 0; i <= N; i++)
			A[i] = sc.nextInt(); int i = 0; int i = 0; i 0 i <= N i N i++ i++ i A[i] = sc.nextInt(); A[i] = sc.nextInt() A[i] A i sc.nextInt() sc.nextInt sc long[] B = new long[N]; B new long[N] N 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] B i sc.nextInt() sc.nextInt sc ans += Math.min(A[0], B[0]) ans Math.min(A[0], B[0]) Math.min Math A[0] A 0 B[0] B 0 B[0] = Math.max(B[0] - A[0], 0) B[0] B 0 Math.max(B[0] - A[0], 0) Math.max Math B[0] - A[0] B[0] B 0 A[0] A 0 0 ans += Math.min(A[N], B[N-1]) ans Math.min(A[N], B[N-1]) Math.min Math A[N] A N B[N-1] B N-1 N 1 B[N-1] = Math.max(B[N-1] - A[N], 0) B[N-1] B N-1 N 1 Math.max(B[N-1] - A[N], 0) Math.max Math B[N-1] - A[N] B[N-1] B N-1 N 1 A[N] A N 0 for(int i = 1; i < N; i++) {
			ans += Math.min(A[i], B[i-1]);
			A[i] = Math.max(A[i] - B[i-1], 0);
			ans += Math.min(A[i], B[i]);
			B[i] = Math.max(B[i] - A[i], 0);
		} int i = 1; int i = 1; i 1 i < N i N i++ i++ i {
			ans += Math.min(A[i], B[i-1]);
			A[i] = Math.max(A[i] - B[i-1], 0);
			ans += Math.min(A[i], B[i]);
			B[i] = Math.max(B[i] - A[i], 0);
		} {
			ans += Math.min(A[i], B[i-1]);
			A[i] = Math.max(A[i] - B[i-1], 0);
			ans += Math.min(A[i], B[i]);
			B[i] = Math.max(B[i] - A[i], 0);
		} ans += Math.min(A[i], B[i-1]) ans Math.min(A[i], B[i-1]) Math.min Math A[i] A i B[i-1] B i-1 i 1 A[i] = Math.max(A[i] - B[i-1], 0) A[i] A i Math.max(A[i] - B[i-1], 0) Math.max Math A[i] - B[i-1] A[i] A i B[i-1] B i-1 i 1 0 ans += Math.min(A[i], B[i]) ans Math.min(A[i], B[i]) Math.min Math A[i] A i B[i] B i B[i] = Math.max(B[i] - A[i], 0) B[i] B i Math.max(B[i] - A[i], 0) Math.max Math B[i] - A[i] B[i] B i A[i] A i 0 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 = sc.nextInt();
		long ans = 0;
		long[] A = new long[N+1];
		for(int i = 0; i <= N; i++)
			A[i] = sc.nextInt();
		long[] B = new long[N];
		for(int i = 0; i < N; i++)
			B[i] = sc.nextInt();
		ans += Math.min(A[0], B[0]);
		B[0] = Math.max(B[0] - A[0], 0);
		ans += Math.min(A[N], B[N-1]);
		B[N-1] = Math.max(B[N-1] - A[N], 0);
		for(int i = 1; i < N; i++) {
			ans += Math.min(A[i], B[i-1]);
			A[i] = Math.max(A[i] - B[i-1], 0);
			ans += Math.min(A[i], B[i]);
			B[i] = Math.max(B[i] - A[i], 0);
		}
		System.out.println(ans);

	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long ans = 0;
		long[] A = new long[N+1];
		for(int i = 0; i <= N; i++)
			A[i] = sc.nextInt();
		long[] B = new long[N];
		for(int i = 0; i < N; i++)
			B[i] = sc.nextInt();
		ans += Math.min(A[0], B[0]);
		B[0] = Math.max(B[0] - A[0], 0);
		ans += Math.min(A[N], B[N-1]);
		B[N-1] = Math.max(B[N-1] - A[N], 0);
		for(int i = 1; i < N; i++) {
			ans += Math.min(A[i], B[i-1]);
			A[i] = Math.max(A[i] - B[i-1], 0);
			ans += Math.min(A[i], B[i]);
			B[i] = Math.max(B[i] - A[i], 0);
		}
		System.out.println(ans);

	}

} Main
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long ans = 0;
		long[] A = new long[N+1];
		for(int i = 0; i <= N; i++)
			A[i] = sc.nextInt();
		long[] B = new long[N];
		for(int i = 0; i < N; i++)
			B[i] = sc.nextInt();
		ans += Math.min(A[0], B[0]);
		B[0] = Math.max(B[0] - A[0], 0);
		ans += Math.min(A[N], B[N-1]);
		B[N-1] = Math.max(B[N-1] - A[N], 0);
		for(int i = 1; i < N; i++) {
			ans += Math.min(A[i], B[i-1]);
			A[i] = Math.max(A[i] - B[i-1], 0);
			ans += Math.min(A[i], B[i]);
			B[i] = Math.max(B[i] - A[i], 0);
		}
		System.out.println(ans);

	}

}