import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N+1];
		for(int i=0; i<N+1; i++)
			A[i] = sc.nextInt();
		int[] B = new int[N];
		for(int i=0; i<N; i++)
			B[i] = sc.nextInt();

		long ans = 0;
		
		for(int i=0; i<N; i++) {
			int m1 = Math.min(A[i], B[i]);
			ans += m1;
			A[i] -= m1;
			B[i] -= m1;
			int m2 = Math.min(A[i+1], B[i]);
			ans += m2;
			A[i+1] -= m2;
			B[i] -= m2;
		}

		System.out.println(ans);
		sc.close();
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N+1];
		for(int i=0; i<N+1; i++)
			A[i] = sc.nextInt();
		int[] B = new int[N];
		for(int i=0; i<N; i++)
			B[i] = sc.nextInt();

		long ans = 0;
		
		for(int i=0; i<N; i++) {
			int m1 = Math.min(A[i], B[i]);
			ans += m1;
			A[i] -= m1;
			B[i] -= m1;
			int m2 = Math.min(A[i+1], B[i]);
			ans += m2;
			A[i+1] -= m2;
			B[i] -= m2;
		}

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

		long ans = 0;
		
		for(int i=0; i<N; i++) {
			int m1 = Math.min(A[i], B[i]);
			ans += m1;
			A[i] -= m1;
			B[i] -= m1;
			int m2 = Math.min(A[i+1], B[i]);
			ans += m2;
			A[i+1] -= m2;
			B[i] -= m2;
		}

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

		long ans = 0;
		
		for(int i=0; i<N; i++) {
			int m1 = Math.min(A[i], B[i]);
			ans += m1;
			A[i] -= m1;
			B[i] -= m1;
			int m2 = Math.min(A[i+1], B[i]);
			ans += m2;
			A[i+1] -= m2;
			B[i] -= m2;
		}

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

		long ans = 0;
		
		for(int i=0; i<N; i++) {
			int m1 = Math.min(A[i], B[i]);
			ans += m1;
			A[i] -= m1;
			B[i] -= m1;
			int m2 = Math.min(A[i+1], B[i]);
			ans += m2;
			A[i+1] -= m2;
			B[i] -= m2;
		}

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

		long ans = 0;
		
		for(int i=0; i<N; i++) {
			int m1 = Math.min(A[i], B[i]);
			ans += m1;
			A[i] -= m1;
			B[i] -= m1;
			int m2 = Math.min(A[i+1], B[i]);
			ans += m2;
			A[i+1] -= m2;
			B[i] -= m2;
		}

		System.out.println(ans);
		sc.close();
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N+1];
		for(int i=0; i<N+1; i++)
			A[i] = sc.nextInt();
		int[] B = new int[N];
		for(int i=0; i<N; i++)
			B[i] = sc.nextInt();

		long ans = 0;
		
		for(int i=0; i<N; i++) {
			int m1 = Math.min(A[i], B[i]);
			ans += m1;
			A[i] -= m1;
			B[i] -= m1;
			int m2 = Math.min(A[i+1], B[i]);
			ans += m2;
			A[i+1] -= m2;
			B[i] -= m2;
		}

		System.out.println(ans);
		sc.close();
	}
}