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];
		for (int i = 0; i < N+1; i++) {
			A[i] = sc.nextLong();
		}
		
		long[] B = new long[N];
		for (int i = 0; i < N; i++) {
			B[i] = sc.nextLong();
		}
		
		long ans = 0;
		for (int i = 0; i < B.length; i++) {
			long t = B[i];
			
			long i1 = A[i];
			long i2 = A[i+1];
			
			if (t >= i1) {
				t -= i1;
				ans += i1;
			} else {
				ans += t;
				continue;
			}
			
			if (t >= i2) {
				t -= i2;
				ans += i2;
				A[i+1] = 0;
			} else {
				ans += t;
				A[i+1] -= t;
			}
			
		}
		
		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 = sc.nextInt();
		
		long[] A = new long[N+1];
		for (int i = 0; i < N+1; i++) {
			A[i] = sc.nextLong();
		}
		
		long[] B = new long[N];
		for (int i = 0; i < N; i++) {
			B[i] = sc.nextLong();
		}
		
		long ans = 0;
		for (int i = 0; i < B.length; i++) {
			long t = B[i];
			
			long i1 = A[i];
			long i2 = A[i+1];
			
			if (t >= i1) {
				t -= i1;
				ans += i1;
			} else {
				ans += t;
				continue;
			}
			
			if (t >= i2) {
				t -= i2;
				ans += i2;
				A[i+1] = 0;
			} else {
				ans += t;
				A[i+1] -= t;
			}
			
		}
		
		System.out.println(ans);
		
	}
	
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		long[] A = new long[N+1];
		for (int i = 0; i < N+1; i++) {
			A[i] = sc.nextLong();
		}
		
		long[] B = new long[N];
		for (int i = 0; i < N; i++) {
			B[i] = sc.nextLong();
		}
		
		long ans = 0;
		for (int i = 0; i < B.length; i++) {
			long t = B[i];
			
			long i1 = A[i];
			long i2 = A[i+1];
			
			if (t >= i1) {
				t -= i1;
				ans += i1;
			} else {
				ans += t;
				continue;
			}
			
			if (t >= i2) {
				t -= i2;
				ans += i2;
				A[i+1] = 0;
			} else {
				ans += t;
				A[i+1] -= t;
			}
			
		}
		
		System.out.println(ans);
		
	} main {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		long[] A = new long[N+1];
		for (int i = 0; i < N+1; i++) {
			A[i] = sc.nextLong();
		}
		
		long[] B = new long[N];
		for (int i = 0; i < N; i++) {
			B[i] = sc.nextLong();
		}
		
		long ans = 0;
		for (int i = 0; i < B.length; i++) {
			long t = B[i];
			
			long i1 = A[i];
			long i2 = A[i+1];
			
			if (t >= i1) {
				t -= i1;
				ans += i1;
			} else {
				ans += t;
				continue;
			}
			
			if (t >= i2) {
				t -= i2;
				ans += i2;
				A[i+1] = 0;
			} else {
				ans += t;
				A[i+1] -= t;
			}
			
		}
		
		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[] A = new long[N+1]; A new long[N+1] N+1 N 1 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 long[] B = new long[N]; B new long[N] N 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 ans = 0; ans 0 for (int i = 0; i < B.length; i++) {
			long t = B[i];
			
			long i1 = A[i];
			long i2 = A[i+1];
			
			if (t >= i1) {
				t -= i1;
				ans += i1;
			} else {
				ans += t;
				continue;
			}
			
			if (t >= i2) {
				t -= i2;
				ans += i2;
				A[i+1] = 0;
			} else {
				ans += t;
				A[i+1] -= t;
			}
			
		} int i = 0; int i = 0; i 0 i < B.length i B.length B B.length i++ i++ i {
			long t = B[i];
			
			long i1 = A[i];
			long i2 = A[i+1];
			
			if (t >= i1) {
				t -= i1;
				ans += i1;
			} else {
				ans += t;
				continue;
			}
			
			if (t >= i2) {
				t -= i2;
				ans += i2;
				A[i+1] = 0;
			} else {
				ans += t;
				A[i+1] -= t;
			}
			
		} {
			long t = B[i];
			
			long i1 = A[i];
			long i2 = A[i+1];
			
			if (t >= i1) {
				t -= i1;
				ans += i1;
			} else {
				ans += t;
				continue;
			}
			
			if (t >= i2) {
				t -= i2;
				ans += i2;
				A[i+1] = 0;
			} else {
				ans += t;
				A[i+1] -= t;
			}
			
		} long t = B[i]; t B[i] B i long i1 = A[i]; i1 A[i] A i long i2 = A[i+1]; i2 A[i+1] A i+1 i 1 if (t >= i1) {
				t -= i1;
				ans += i1;
			} else {
				ans += t;
				continue;
			} t >= i1 t i1 {
				t -= i1;
				ans += i1;
			} t -= i1 t i1 ans += i1 ans i1 {
				ans += t;
				continue;
			} ans += t ans t continue; if (t >= i2) {
				t -= i2;
				ans += i2;
				A[i+1] = 0;
			} else {
				ans += t;
				A[i+1] -= t;
			} t >= i2 t i2 {
				t -= i2;
				ans += i2;
				A[i+1] = 0;
			} t -= i2 t i2 ans += i2 ans i2 A[i+1] = 0 A[i+1] A i+1 i 1 0 {
				ans += t;
				A[i+1] -= t;
			} ans += t ans t A[i+1] -= t A[i+1] A i+1 i 1 t 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[] A = new long[N+1];
		for (int i = 0; i < N+1; i++) {
			A[i] = sc.nextLong();
		}
		
		long[] B = new long[N];
		for (int i = 0; i < N; i++) {
			B[i] = sc.nextLong();
		}
		
		long ans = 0;
		for (int i = 0; i < B.length; i++) {
			long t = B[i];
			
			long i1 = A[i];
			long i2 = A[i+1];
			
			if (t >= i1) {
				t -= i1;
				ans += i1;
			} else {
				ans += t;
				continue;
			}
			
			if (t >= i2) {
				t -= i2;
				ans += i2;
				A[i+1] = 0;
			} else {
				ans += t;
				A[i+1] -= t;
			}
			
		}
		
		System.out.println(ans);
		
	}
	
} 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];
		for (int i = 0; i < N+1; i++) {
			A[i] = sc.nextLong();
		}
		
		long[] B = new long[N];
		for (int i = 0; i < N; i++) {
			B[i] = sc.nextLong();
		}
		
		long ans = 0;
		for (int i = 0; i < B.length; i++) {
			long t = B[i];
			
			long i1 = A[i];
			long i2 = A[i+1];
			
			if (t >= i1) {
				t -= i1;
				ans += i1;
			} else {
				ans += t;
				continue;
			}
			
			if (t >= i2) {
				t -= i2;
				ans += i2;
				A[i+1] = 0;
			} else {
				ans += t;
				A[i+1] -= t;
			}
			
		}
		
		System.out.println(ans);
		
	}
	
} 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];
		for (int i = 0; i < N+1; i++) {
			A[i] = sc.nextLong();
		}
		
		long[] B = new long[N];
		for (int i = 0; i < N; i++) {
			B[i] = sc.nextLong();
		}
		
		long ans = 0;
		for (int i = 0; i < B.length; i++) {
			long t = B[i];
			
			long i1 = A[i];
			long i2 = A[i+1];
			
			if (t >= i1) {
				t -= i1;
				ans += i1;
			} else {
				ans += t;
				continue;
			}
			
			if (t >= i2) {
				t -= i2;
				ans += i2;
				A[i+1] = 0;
			} else {
				ans += t;
				A[i+1] -= t;
			}
			
		}
		
		System.out.println(ans);
		
	}
	
}

