import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		
		int N = scan.nextInt();
		int a[] = new int[N + 1];
		int b[] = new int[N];
		for(int i = 0; i < N + 1; i++) {
			a[i] = scan.nextInt();
		}
		
		for(int i = 0; i < N; i++) {
			b[i] = scan.nextInt();
		}
		
		long total = 0;
		for(int i = 0; i < N; i++) {
			if(b[i] <= a[i]) {
				total += b[i];
			}else {
				b[i] -= a[i];
				total += a[i];
				
				int nextBaster = Math.min(a[i + 1], b[i]);
				total += nextBaster;
				a[i + 1] -= nextBaster;
			}
		}
		
		System.out.println(total);
 	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		
		int N = scan.nextInt();
		int a[] = new int[N + 1];
		int b[] = new int[N];
		for(int i = 0; i < N + 1; i++) {
			a[i] = scan.nextInt();
		}
		
		for(int i = 0; i < N; i++) {
			b[i] = scan.nextInt();
		}
		
		long total = 0;
		for(int i = 0; i < N; i++) {
			if(b[i] <= a[i]) {
				total += b[i];
			}else {
				b[i] -= a[i];
				total += a[i];
				
				int nextBaster = Math.min(a[i + 1], b[i]);
				total += nextBaster;
				a[i + 1] -= nextBaster;
			}
		}
		
		System.out.println(total);
 	}
} Main public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		
		int N = scan.nextInt();
		int a[] = new int[N + 1];
		int b[] = new int[N];
		for(int i = 0; i < N + 1; i++) {
			a[i] = scan.nextInt();
		}
		
		for(int i = 0; i < N; i++) {
			b[i] = scan.nextInt();
		}
		
		long total = 0;
		for(int i = 0; i < N; i++) {
			if(b[i] <= a[i]) {
				total += b[i];
			}else {
				b[i] -= a[i];
				total += a[i];
				
				int nextBaster = Math.min(a[i + 1], b[i]);
				total += nextBaster;
				a[i + 1] -= nextBaster;
			}
		}
		
		System.out.println(total);
 	} main {

		Scanner scan = new Scanner(System.in);
		
		int N = scan.nextInt();
		int a[] = new int[N + 1];
		int b[] = new int[N];
		for(int i = 0; i < N + 1; i++) {
			a[i] = scan.nextInt();
		}
		
		for(int i = 0; i < N; i++) {
			b[i] = scan.nextInt();
		}
		
		long total = 0;
		for(int i = 0; i < N; i++) {
			if(b[i] <= a[i]) {
				total += b[i];
			}else {
				b[i] -= a[i];
				total += a[i];
				
				int nextBaster = Math.min(a[i + 1], b[i]);
				total += nextBaster;
				a[i + 1] -= nextBaster;
			}
		}
		
		System.out.println(total);
 	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan int a[] = new int[N + 1]; a new int[N + 1] N + 1 N 1 int b[] = new int[N]; b new int[N] N for(int i = 0; i < N + 1; i++) {
			a[i] = scan.nextInt();
		} int i = 0; int i = 0; i 0 i < N + 1 i N + 1 N 1 i++ i++ i {
			a[i] = scan.nextInt();
		} {
			a[i] = scan.nextInt();
		} a[i] = scan.nextInt() a[i] a i scan.nextInt() scan.nextInt scan for(int i = 0; i < N; i++) {
			b[i] = scan.nextInt();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			b[i] = scan.nextInt();
		} {
			b[i] = scan.nextInt();
		} b[i] = scan.nextInt() b[i] b i scan.nextInt() scan.nextInt scan long total = 0; total 0 for(int i = 0; i < N; i++) {
			if(b[i] <= a[i]) {
				total += b[i];
			}else {
				b[i] -= a[i];
				total += a[i];
				
				int nextBaster = Math.min(a[i + 1], b[i]);
				total += nextBaster;
				a[i + 1] -= nextBaster;
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			if(b[i] <= a[i]) {
				total += b[i];
			}else {
				b[i] -= a[i];
				total += a[i];
				
				int nextBaster = Math.min(a[i + 1], b[i]);
				total += nextBaster;
				a[i + 1] -= nextBaster;
			}
		} {
			if(b[i] <= a[i]) {
				total += b[i];
			}else {
				b[i] -= a[i];
				total += a[i];
				
				int nextBaster = Math.min(a[i + 1], b[i]);
				total += nextBaster;
				a[i + 1] -= nextBaster;
			}
		} if(b[i] <= a[i]) {
				total += b[i];
			}else {
				b[i] -= a[i];
				total += a[i];
				
				int nextBaster = Math.min(a[i + 1], b[i]);
				total += nextBaster;
				a[i + 1] -= nextBaster;
			} b[i] <= a[i] b[i] b i a[i] a i {
				total += b[i];
			} total += b[i] total b[i] b i {
				b[i] -= a[i];
				total += a[i];
				
				int nextBaster = Math.min(a[i + 1], b[i]);
				total += nextBaster;
				a[i + 1] -= nextBaster;
			} b[i] -= a[i] b[i] b i a[i] a i total += a[i] total a[i] a i int nextBaster = Math.min(a[i + 1], b[i]); nextBaster Math.min(a[i + 1], b[i]) Math.min Math a[i + 1] a i + 1 i 1 b[i] b i total += nextBaster total nextBaster a[i + 1] -= nextBaster a[i + 1] a i + 1 i 1 nextBaster System.out.println(total) System.out.println System.out System System.out total String[] args args public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		
		int N = scan.nextInt();
		int a[] = new int[N + 1];
		int b[] = new int[N];
		for(int i = 0; i < N + 1; i++) {
			a[i] = scan.nextInt();
		}
		
		for(int i = 0; i < N; i++) {
			b[i] = scan.nextInt();
		}
		
		long total = 0;
		for(int i = 0; i < N; i++) {
			if(b[i] <= a[i]) {
				total += b[i];
			}else {
				b[i] -= a[i];
				total += a[i];
				
				int nextBaster = Math.min(a[i + 1], b[i]);
				total += nextBaster;
				a[i + 1] -= nextBaster;
			}
		}
		
		System.out.println(total);
 	}
} public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		
		int N = scan.nextInt();
		int a[] = new int[N + 1];
		int b[] = new int[N];
		for(int i = 0; i < N + 1; i++) {
			a[i] = scan.nextInt();
		}
		
		for(int i = 0; i < N; i++) {
			b[i] = scan.nextInt();
		}
		
		long total = 0;
		for(int i = 0; i < N; i++) {
			if(b[i] <= a[i]) {
				total += b[i];
			}else {
				b[i] -= a[i];
				total += a[i];
				
				int nextBaster = Math.min(a[i + 1], b[i]);
				total += nextBaster;
				a[i + 1] -= nextBaster;
			}
		}
		
		System.out.println(total);
 	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		
		int N = scan.nextInt();
		int a[] = new int[N + 1];
		int b[] = new int[N];
		for(int i = 0; i < N + 1; i++) {
			a[i] = scan.nextInt();
		}
		
		for(int i = 0; i < N; i++) {
			b[i] = scan.nextInt();
		}
		
		long total = 0;
		for(int i = 0; i < N; i++) {
			if(b[i] <= a[i]) {
				total += b[i];
			}else {
				b[i] -= a[i];
				total += a[i];
				
				int nextBaster = Math.min(a[i + 1], b[i]);
				total += nextBaster;
				a[i + 1] -= nextBaster;
			}
		}
		
		System.out.println(total);
 	}
}
