import java.util.*;

public class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();
		long a[] = new long[N+1];
		for(int i=0;i<N+1;i++) a[i]=scanner.nextInt();
		long b[] = new long[N];
		for(int i=0;i<N;i++) b[i]=scanner.nextInt();

		long defeated=0;



		for(int i=0;i<N;i++) {
			long tmp1 = b[i];
			long tmp2 = a[i];
			b[i]-= a[i];
			a[i]-= tmp1;
			if(b[i] >= 0) {
				defeated += tmp2;
				long tmp3=b[i];
				long tmp4=a[i+1];
				b[i] -= a[i+1];
				if(b[i] >= 0) {
					defeated += tmp4;
					a[i+1]=0;

				}else {
					a[i+1] -= tmp3;
					defeated += tmp3;
				}

			}else defeated +=tmp1;

//			System.out.println("defeated[" + i + "]=" + defeated);
		}

		System.out.println(defeated);

		scanner.close();
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();
		long a[] = new long[N+1];
		for(int i=0;i<N+1;i++) a[i]=scanner.nextInt();
		long b[] = new long[N];
		for(int i=0;i<N;i++) b[i]=scanner.nextInt();

		long defeated=0;



		for(int i=0;i<N;i++) {
			long tmp1 = b[i];
			long tmp2 = a[i];
			b[i]-= a[i];
			a[i]-= tmp1;
			if(b[i] >= 0) {
				defeated += tmp2;
				long tmp3=b[i];
				long tmp4=a[i+1];
				b[i] -= a[i+1];
				if(b[i] >= 0) {
					defeated += tmp4;
					a[i+1]=0;

				}else {
					a[i+1] -= tmp3;
					defeated += tmp3;
				}

			}else defeated +=tmp1;

//			System.out.println("defeated[" + i + "]=" + defeated);
		}

		System.out.println(defeated);

		scanner.close();
	}
} Main public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();
		long a[] = new long[N+1];
		for(int i=0;i<N+1;i++) a[i]=scanner.nextInt();
		long b[] = new long[N];
		for(int i=0;i<N;i++) b[i]=scanner.nextInt();

		long defeated=0;



		for(int i=0;i<N;i++) {
			long tmp1 = b[i];
			long tmp2 = a[i];
			b[i]-= a[i];
			a[i]-= tmp1;
			if(b[i] >= 0) {
				defeated += tmp2;
				long tmp3=b[i];
				long tmp4=a[i+1];
				b[i] -= a[i+1];
				if(b[i] >= 0) {
					defeated += tmp4;
					a[i+1]=0;

				}else {
					a[i+1] -= tmp3;
					defeated += tmp3;
				}

			}else defeated +=tmp1;

//			System.out.println("defeated[" + i + "]=" + defeated);
		}

		System.out.println(defeated);

		scanner.close();
	} main {

		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();
		long a[] = new long[N+1];
		for(int i=0;i<N+1;i++) a[i]=scanner.nextInt();
		long b[] = new long[N];
		for(int i=0;i<N;i++) b[i]=scanner.nextInt();

		long defeated=0;



		for(int i=0;i<N;i++) {
			long tmp1 = b[i];
			long tmp2 = a[i];
			b[i]-= a[i];
			a[i]-= tmp1;
			if(b[i] >= 0) {
				defeated += tmp2;
				long tmp3=b[i];
				long tmp4=a[i+1];
				b[i] -= a[i+1];
				if(b[i] >= 0) {
					defeated += tmp4;
					a[i+1]=0;

				}else {
					a[i+1] -= tmp3;
					defeated += tmp3;
				}

			}else defeated +=tmp1;

//			System.out.println("defeated[" + i + "]=" + defeated);
		}

		System.out.println(defeated);

		scanner.close();
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner 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]=scanner.nextInt(); int i=0; int i=0; i 0 i<N+1 i N+1 N 1 i++ i++ i a[i]=scanner.nextInt(); a[i]=scanner.nextInt() a[i] a i scanner.nextInt() scanner.nextInt scanner long b[] = new long[N]; b new long[N] N for(int i=0;i<N;i++) b[i]=scanner.nextInt(); int i=0; int i=0; i 0 i<N i N i++ i++ i b[i]=scanner.nextInt(); b[i]=scanner.nextInt() b[i] b i scanner.nextInt() scanner.nextInt scanner long defeated=0; defeated 0 for(int i=0;i<N;i++) {
			long tmp1 = b[i];
			long tmp2 = a[i];
			b[i]-= a[i];
			a[i]-= tmp1;
			if(b[i] >= 0) {
				defeated += tmp2;
				long tmp3=b[i];
				long tmp4=a[i+1];
				b[i] -= a[i+1];
				if(b[i] >= 0) {
					defeated += tmp4;
					a[i+1]=0;

				}else {
					a[i+1] -= tmp3;
					defeated += tmp3;
				}

			}else defeated +=tmp1;

//			System.out.println("defeated[" + i + "]=" + defeated);
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			long tmp1 = b[i];
			long tmp2 = a[i];
			b[i]-= a[i];
			a[i]-= tmp1;
			if(b[i] >= 0) {
				defeated += tmp2;
				long tmp3=b[i];
				long tmp4=a[i+1];
				b[i] -= a[i+1];
				if(b[i] >= 0) {
					defeated += tmp4;
					a[i+1]=0;

				}else {
					a[i+1] -= tmp3;
					defeated += tmp3;
				}

			}else defeated +=tmp1;

//			System.out.println("defeated[" + i + "]=" + defeated);
		} {
			long tmp1 = b[i];
			long tmp2 = a[i];
			b[i]-= a[i];
			a[i]-= tmp1;
			if(b[i] >= 0) {
				defeated += tmp2;
				long tmp3=b[i];
				long tmp4=a[i+1];
				b[i] -= a[i+1];
				if(b[i] >= 0) {
					defeated += tmp4;
					a[i+1]=0;

				}else {
					a[i+1] -= tmp3;
					defeated += tmp3;
				}

			}else defeated +=tmp1;

//			System.out.println("defeated[" + i + "]=" + defeated);
		} long tmp1 = b[i]; tmp1 b[i] b i long tmp2 = a[i]; tmp2 a[i] a i b[i]-= a[i] b[i] b i a[i] a i a[i]-= tmp1 a[i] a i tmp1 if(b[i] >= 0) {
				defeated += tmp2;
				long tmp3=b[i];
				long tmp4=a[i+1];
				b[i] -= a[i+1];
				if(b[i] >= 0) {
					defeated += tmp4;
					a[i+1]=0;

				}else {
					a[i+1] -= tmp3;
					defeated += tmp3;
				}

			}else defeated +=tmp1; b[i] >= 0 b[i] b i 0 {
				defeated += tmp2;
				long tmp3=b[i];
				long tmp4=a[i+1];
				b[i] -= a[i+1];
				if(b[i] >= 0) {
					defeated += tmp4;
					a[i+1]=0;

				}else {
					a[i+1] -= tmp3;
					defeated += tmp3;
				}

			} defeated += tmp2 defeated tmp2 long tmp3=b[i]; tmp3 b[i] b i long tmp4=a[i+1]; tmp4 a[i+1] a i+1 i 1 b[i] -= a[i+1] b[i] b i a[i+1] a i+1 i 1 if(b[i] >= 0) {
					defeated += tmp4;
					a[i+1]=0;

				}else {
					a[i+1] -= tmp3;
					defeated += tmp3;
				} b[i] >= 0 b[i] b i 0 {
					defeated += tmp4;
					a[i+1]=0;

				} defeated += tmp4 defeated tmp4 a[i+1]=0 a[i+1] a i+1 i 1 0 {
					a[i+1] -= tmp3;
					defeated += tmp3;
				} a[i+1] -= tmp3 a[i+1] a i+1 i 1 tmp3 defeated += tmp3 defeated tmp3 defeated +=tmp1 defeated tmp1 System.out.println(defeated) System.out.println System.out System System.out defeated scanner.close() scanner.close scanner String[] args args public class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();
		long a[] = new long[N+1];
		for(int i=0;i<N+1;i++) a[i]=scanner.nextInt();
		long b[] = new long[N];
		for(int i=0;i<N;i++) b[i]=scanner.nextInt();

		long defeated=0;



		for(int i=0;i<N;i++) {
			long tmp1 = b[i];
			long tmp2 = a[i];
			b[i]-= a[i];
			a[i]-= tmp1;
			if(b[i] >= 0) {
				defeated += tmp2;
				long tmp3=b[i];
				long tmp4=a[i+1];
				b[i] -= a[i+1];
				if(b[i] >= 0) {
					defeated += tmp4;
					a[i+1]=0;

				}else {
					a[i+1] -= tmp3;
					defeated += tmp3;
				}

			}else defeated +=tmp1;

//			System.out.println("defeated[" + i + "]=" + defeated);
		}

		System.out.println(defeated);

		scanner.close();
	}
} public class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();
		long a[] = new long[N+1];
		for(int i=0;i<N+1;i++) a[i]=scanner.nextInt();
		long b[] = new long[N];
		for(int i=0;i<N;i++) b[i]=scanner.nextInt();

		long defeated=0;



		for(int i=0;i<N;i++) {
			long tmp1 = b[i];
			long tmp2 = a[i];
			b[i]-= a[i];
			a[i]-= tmp1;
			if(b[i] >= 0) {
				defeated += tmp2;
				long tmp3=b[i];
				long tmp4=a[i+1];
				b[i] -= a[i+1];
				if(b[i] >= 0) {
					defeated += tmp4;
					a[i+1]=0;

				}else {
					a[i+1] -= tmp3;
					defeated += tmp3;
				}

			}else defeated +=tmp1;

//			System.out.println("defeated[" + i + "]=" + defeated);
		}

		System.out.println(defeated);

		scanner.close();
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();
		long a[] = new long[N+1];
		for(int i=0;i<N+1;i++) a[i]=scanner.nextInt();
		long b[] = new long[N];
		for(int i=0;i<N;i++) b[i]=scanner.nextInt();

		long defeated=0;



		for(int i=0;i<N;i++) {
			long tmp1 = b[i];
			long tmp2 = a[i];
			b[i]-= a[i];
			a[i]-= tmp1;
			if(b[i] >= 0) {
				defeated += tmp2;
				long tmp3=b[i];
				long tmp4=a[i+1];
				b[i] -= a[i+1];
				if(b[i] >= 0) {
					defeated += tmp4;
					a[i+1]=0;

				}else {
					a[i+1] -= tmp3;
					defeated += tmp3;
				}

			}else defeated +=tmp1;

//			System.out.println("defeated[" + i + "]=" + defeated);
		}

		System.out.println(defeated);

		scanner.close();
	}
}
