import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			
			int N = scan.nextInt();
			long[]A = new long[N+1];
			long[]B = new long[N];
			
			for(int i = 0;i<N+1;i++)A[i] = scan.nextLong();
			for(int i = 0;i<N;i++)B[i] = scan.nextLong();
			
			long goukei = 0;
			
			for(int i = 0;i<N;i++) {
				if(A[i]>B[i]) {
					goukei+=B[i];
				}else{
					goukei+=A[i];
					B[i]-=A[i];
					if(A[i+1]>=B[i]) {
						goukei+=B[i];
						A[i+1]-=B[i];
					}else {
						goukei+=A[i+1];
						A[i+1] = 0;
					}
						
				}
			}
			
			
			System.out.println(goukei);
			
			
			
			
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			
			int N = scan.nextInt();
			long[]A = new long[N+1];
			long[]B = new long[N];
			
			for(int i = 0;i<N+1;i++)A[i] = scan.nextLong();
			for(int i = 0;i<N;i++)B[i] = scan.nextLong();
			
			long goukei = 0;
			
			for(int i = 0;i<N;i++) {
				if(A[i]>B[i]) {
					goukei+=B[i];
				}else{
					goukei+=A[i];
					B[i]-=A[i];
					if(A[i+1]>=B[i]) {
						goukei+=B[i];
						A[i+1]-=B[i];
					}else {
						goukei+=A[i+1];
						A[i+1] = 0;
					}
						
				}
			}
			
			
			System.out.println(goukei);
			
			
			
			
		}
	}
} Main public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			
			int N = scan.nextInt();
			long[]A = new long[N+1];
			long[]B = new long[N];
			
			for(int i = 0;i<N+1;i++)A[i] = scan.nextLong();
			for(int i = 0;i<N;i++)B[i] = scan.nextLong();
			
			long goukei = 0;
			
			for(int i = 0;i<N;i++) {
				if(A[i]>B[i]) {
					goukei+=B[i];
				}else{
					goukei+=A[i];
					B[i]-=A[i];
					if(A[i+1]>=B[i]) {
						goukei+=B[i];
						A[i+1]-=B[i];
					}else {
						goukei+=A[i+1];
						A[i+1] = 0;
					}
						
				}
			}
			
			
			System.out.println(goukei);
			
			
			
			
		}
	} main {
		try(Scanner scan = new Scanner(System.in)){
			
			
			int N = scan.nextInt();
			long[]A = new long[N+1];
			long[]B = new long[N];
			
			for(int i = 0;i<N+1;i++)A[i] = scan.nextLong();
			for(int i = 0;i<N;i++)B[i] = scan.nextLong();
			
			long goukei = 0;
			
			for(int i = 0;i<N;i++) {
				if(A[i]>B[i]) {
					goukei+=B[i];
				}else{
					goukei+=A[i];
					B[i]-=A[i];
					if(A[i+1]>=B[i]) {
						goukei+=B[i];
						A[i+1]-=B[i];
					}else {
						goukei+=A[i+1];
						A[i+1] = 0;
					}
						
				}
			}
			
			
			System.out.println(goukei);
			
			
			
			
		}
	} try(Scanner scan = new Scanner(System.in)){
			
			
			int N = scan.nextInt();
			long[]A = new long[N+1];
			long[]B = new long[N];
			
			for(int i = 0;i<N+1;i++)A[i] = scan.nextLong();
			for(int i = 0;i<N;i++)B[i] = scan.nextLong();
			
			long goukei = 0;
			
			for(int i = 0;i<N;i++) {
				if(A[i]>B[i]) {
					goukei+=B[i];
				}else{
					goukei+=A[i];
					B[i]-=A[i];
					if(A[i+1]>=B[i]) {
						goukei+=B[i];
						A[i+1]-=B[i];
					}else {
						goukei+=A[i+1];
						A[i+1] = 0;
					}
						
				}
			}
			
			
			System.out.println(goukei);
			
			
			
			
		} {
			
			
			int N = scan.nextInt();
			long[]A = new long[N+1];
			long[]B = new long[N];
			
			for(int i = 0;i<N+1;i++)A[i] = scan.nextLong();
			for(int i = 0;i<N;i++)B[i] = scan.nextLong();
			
			long goukei = 0;
			
			for(int i = 0;i<N;i++) {
				if(A[i]>B[i]) {
					goukei+=B[i];
				}else{
					goukei+=A[i];
					B[i]-=A[i];
					if(A[i+1]>=B[i]) {
						goukei+=B[i];
						A[i+1]-=B[i];
					}else {
						goukei+=A[i+1];
						A[i+1] = 0;
					}
						
				}
			}
			
			
			System.out.println(goukei);
			
			
			
			
		} Scanner scan = new Scanner(System.in) Scanner scan = new Scanner(System.in) new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan long[]A = new long[N+1]; A new long[N+1] N+1 N 1 long[]B = new long[N]; B new long[N] N for(int i = 0;i<N+1;i++)A[i] = scan.nextLong(); int i = 0; int i = 0; i 0 i<N+1 i N+1 N 1 i++ i++ i A[i] = scan.nextLong(); A[i] = scan.nextLong() A[i] A i scan.nextLong() scan.nextLong scan for(int i = 0;i<N;i++)B[i] = scan.nextLong(); int i = 0; int i = 0; i 0 i<N i N i++ i++ i B[i] = scan.nextLong(); B[i] = scan.nextLong() B[i] B i scan.nextLong() scan.nextLong scan long goukei = 0; goukei 0 for(int i = 0;i<N;i++) {
				if(A[i]>B[i]) {
					goukei+=B[i];
				}else{
					goukei+=A[i];
					B[i]-=A[i];
					if(A[i+1]>=B[i]) {
						goukei+=B[i];
						A[i+1]-=B[i];
					}else {
						goukei+=A[i+1];
						A[i+1] = 0;
					}
						
				}
			} int i = 0; int i = 0; i 0 i<N i N i++ i++ i {
				if(A[i]>B[i]) {
					goukei+=B[i];
				}else{
					goukei+=A[i];
					B[i]-=A[i];
					if(A[i+1]>=B[i]) {
						goukei+=B[i];
						A[i+1]-=B[i];
					}else {
						goukei+=A[i+1];
						A[i+1] = 0;
					}
						
				}
			} {
				if(A[i]>B[i]) {
					goukei+=B[i];
				}else{
					goukei+=A[i];
					B[i]-=A[i];
					if(A[i+1]>=B[i]) {
						goukei+=B[i];
						A[i+1]-=B[i];
					}else {
						goukei+=A[i+1];
						A[i+1] = 0;
					}
						
				}
			} if(A[i]>B[i]) {
					goukei+=B[i];
				}else{
					goukei+=A[i];
					B[i]-=A[i];
					if(A[i+1]>=B[i]) {
						goukei+=B[i];
						A[i+1]-=B[i];
					}else {
						goukei+=A[i+1];
						A[i+1] = 0;
					}
						
				} A[i]>B[i] A[i] A i B[i] B i {
					goukei+=B[i];
				} goukei+=B[i] goukei B[i] B i {
					goukei+=A[i];
					B[i]-=A[i];
					if(A[i+1]>=B[i]) {
						goukei+=B[i];
						A[i+1]-=B[i];
					}else {
						goukei+=A[i+1];
						A[i+1] = 0;
					}
						
				} goukei+=A[i] goukei A[i] A i B[i]-=A[i] B[i] B i A[i] A i if(A[i+1]>=B[i]) {
						goukei+=B[i];
						A[i+1]-=B[i];
					}else {
						goukei+=A[i+1];
						A[i+1] = 0;
					} A[i+1]>=B[i] A[i+1] A i+1 i 1 B[i] B i {
						goukei+=B[i];
						A[i+1]-=B[i];
					} goukei+=B[i] goukei B[i] B i A[i+1]-=B[i] A[i+1] A i+1 i 1 B[i] B i {
						goukei+=A[i+1];
						A[i+1] = 0;
					} goukei+=A[i+1] goukei A[i+1] A i+1 i 1 A[i+1] = 0 A[i+1] A i+1 i 1 0 System.out.println(goukei) System.out.println System.out System System.out goukei String[]args args public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			
			int N = scan.nextInt();
			long[]A = new long[N+1];
			long[]B = new long[N];
			
			for(int i = 0;i<N+1;i++)A[i] = scan.nextLong();
			for(int i = 0;i<N;i++)B[i] = scan.nextLong();
			
			long goukei = 0;
			
			for(int i = 0;i<N;i++) {
				if(A[i]>B[i]) {
					goukei+=B[i];
				}else{
					goukei+=A[i];
					B[i]-=A[i];
					if(A[i+1]>=B[i]) {
						goukei+=B[i];
						A[i+1]-=B[i];
					}else {
						goukei+=A[i+1];
						A[i+1] = 0;
					}
						
				}
			}
			
			
			System.out.println(goukei);
			
			
			
			
		}
	}
} public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			
			int N = scan.nextInt();
			long[]A = new long[N+1];
			long[]B = new long[N];
			
			for(int i = 0;i<N+1;i++)A[i] = scan.nextLong();
			for(int i = 0;i<N;i++)B[i] = scan.nextLong();
			
			long goukei = 0;
			
			for(int i = 0;i<N;i++) {
				if(A[i]>B[i]) {
					goukei+=B[i];
				}else{
					goukei+=A[i];
					B[i]-=A[i];
					if(A[i+1]>=B[i]) {
						goukei+=B[i];
						A[i+1]-=B[i];
					}else {
						goukei+=A[i+1];
						A[i+1] = 0;
					}
						
				}
			}
			
			
			System.out.println(goukei);
			
			
			
			
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			
			int N = scan.nextInt();
			long[]A = new long[N+1];
			long[]B = new long[N];
			
			for(int i = 0;i<N+1;i++)A[i] = scan.nextLong();
			for(int i = 0;i<N;i++)B[i] = scan.nextLong();
			
			long goukei = 0;
			
			for(int i = 0;i<N;i++) {
				if(A[i]>B[i]) {
					goukei+=B[i];
				}else{
					goukei+=A[i];
					B[i]-=A[i];
					if(A[i+1]>=B[i]) {
						goukei+=B[i];
						A[i+1]-=B[i];
					}else {
						goukei+=A[i+1];
						A[i+1] = 0;
					}
						
				}
			}
			
			
			System.out.println(goukei);
			
			
			
			
		}
	}
}
