import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			long[] a = new long[n+1];
			long[] b = new long[n];
			
			for(int i = 0 ; i < n+1; i++ ) {
				a[i] = sc.nextInt();
			}
			for(int i = 0 ; i < n ; i++ ) {
				b[i] = sc.nextInt();
			}
			
			long count = 0;
			for(int j = 0 ; j < n ; j++ ) {

				if ( a[j] < b[j]) {
					count += a[j];
					long rest = b[j] - a[j];
					if ( a[j+1] < rest ) {
						count+= a[j+1];
						a[j+1] = 0;
					}
					else {
						count+=rest;
						a[j+1] = a[j+1] - rest;
					}
				}
				else {
					count+= b[j];
				}
			}
			
			System.out.println(count);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			long[] a = new long[n+1];
			long[] b = new long[n];
			
			for(int i = 0 ; i < n+1; i++ ) {
				a[i] = sc.nextInt();
			}
			for(int i = 0 ; i < n ; i++ ) {
				b[i] = sc.nextInt();
			}
			
			long count = 0;
			for(int j = 0 ; j < n ; j++ ) {

				if ( a[j] < b[j]) {
					count += a[j];
					long rest = b[j] - a[j];
					if ( a[j+1] < rest ) {
						count+= a[j+1];
						a[j+1] = 0;
					}
					else {
						count+=rest;
						a[j+1] = a[j+1] - rest;
					}
				}
				else {
					count+= b[j];
				}
			}
			
			System.out.println(count);
		}
	}
} Main public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			long[] a = new long[n+1];
			long[] b = new long[n];
			
			for(int i = 0 ; i < n+1; i++ ) {
				a[i] = sc.nextInt();
			}
			for(int i = 0 ; i < n ; i++ ) {
				b[i] = sc.nextInt();
			}
			
			long count = 0;
			for(int j = 0 ; j < n ; j++ ) {

				if ( a[j] < b[j]) {
					count += a[j];
					long rest = b[j] - a[j];
					if ( a[j+1] < rest ) {
						count+= a[j+1];
						a[j+1] = 0;
					}
					else {
						count+=rest;
						a[j+1] = a[j+1] - rest;
					}
				}
				else {
					count+= b[j];
				}
			}
			
			System.out.println(count);
		}
	} main {
		try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			long[] a = new long[n+1];
			long[] b = new long[n];
			
			for(int i = 0 ; i < n+1; i++ ) {
				a[i] = sc.nextInt();
			}
			for(int i = 0 ; i < n ; i++ ) {
				b[i] = sc.nextInt();
			}
			
			long count = 0;
			for(int j = 0 ; j < n ; j++ ) {

				if ( a[j] < b[j]) {
					count += a[j];
					long rest = b[j] - a[j];
					if ( a[j+1] < rest ) {
						count+= a[j+1];
						a[j+1] = 0;
					}
					else {
						count+=rest;
						a[j+1] = a[j+1] - rest;
					}
				}
				else {
					count+= b[j];
				}
			}
			
			System.out.println(count);
		}
	} try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			long[] a = new long[n+1];
			long[] b = new long[n];
			
			for(int i = 0 ; i < n+1; i++ ) {
				a[i] = sc.nextInt();
			}
			for(int i = 0 ; i < n ; i++ ) {
				b[i] = sc.nextInt();
			}
			
			long count = 0;
			for(int j = 0 ; j < n ; j++ ) {

				if ( a[j] < b[j]) {
					count += a[j];
					long rest = b[j] - a[j];
					if ( a[j+1] < rest ) {
						count+= a[j+1];
						a[j+1] = 0;
					}
					else {
						count+=rest;
						a[j+1] = a[j+1] - rest;
					}
				}
				else {
					count+= b[j];
				}
			}
			
			System.out.println(count);
		} {

			int n = sc.nextInt();
			long[] a = new long[n+1];
			long[] b = new long[n];
			
			for(int i = 0 ; i < n+1; i++ ) {
				a[i] = sc.nextInt();
			}
			for(int i = 0 ; i < n ; i++ ) {
				b[i] = sc.nextInt();
			}
			
			long count = 0;
			for(int j = 0 ; j < n ; j++ ) {

				if ( a[j] < b[j]) {
					count += a[j];
					long rest = b[j] - a[j];
					if ( a[j+1] < rest ) {
						count+= a[j+1];
						a[j+1] = 0;
					}
					else {
						count+=rest;
						a[j+1] = a[j+1] - rest;
					}
				}
				else {
					count+= b[j];
				}
			}
			
			System.out.println(count);
		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) 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 long[] b = new long[n]; b new long[n] n 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] = sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc 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] = sc.nextInt() b[i] b i sc.nextInt() sc.nextInt sc long count = 0; count 0 for(int j = 0 ; j < n ; j++ ) {

				if ( a[j] < b[j]) {
					count += a[j];
					long rest = b[j] - a[j];
					if ( a[j+1] < rest ) {
						count+= a[j+1];
						a[j+1] = 0;
					}
					else {
						count+=rest;
						a[j+1] = a[j+1] - rest;
					}
				}
				else {
					count+= b[j];
				}
			} int j = 0 ; int j = 0 ; j 0 j < n j n j++ j++ j {

				if ( a[j] < b[j]) {
					count += a[j];
					long rest = b[j] - a[j];
					if ( a[j+1] < rest ) {
						count+= a[j+1];
						a[j+1] = 0;
					}
					else {
						count+=rest;
						a[j+1] = a[j+1] - rest;
					}
				}
				else {
					count+= b[j];
				}
			} {

				if ( a[j] < b[j]) {
					count += a[j];
					long rest = b[j] - a[j];
					if ( a[j+1] < rest ) {
						count+= a[j+1];
						a[j+1] = 0;
					}
					else {
						count+=rest;
						a[j+1] = a[j+1] - rest;
					}
				}
				else {
					count+= b[j];
				}
			} if ( a[j] < b[j]) {
					count += a[j];
					long rest = b[j] - a[j];
					if ( a[j+1] < rest ) {
						count+= a[j+1];
						a[j+1] = 0;
					}
					else {
						count+=rest;
						a[j+1] = a[j+1] - rest;
					}
				}
				else {
					count+= b[j];
				} a[j] < b[j] a[j] a j b[j] b j {
					count += a[j];
					long rest = b[j] - a[j];
					if ( a[j+1] < rest ) {
						count+= a[j+1];
						a[j+1] = 0;
					}
					else {
						count+=rest;
						a[j+1] = a[j+1] - rest;
					}
				} count += a[j] count a[j] a j long rest = b[j] - a[j]; rest b[j] - a[j] b[j] b j a[j] a j if ( a[j+1] < rest ) {
						count+= a[j+1];
						a[j+1] = 0;
					}
					else {
						count+=rest;
						a[j+1] = a[j+1] - rest;
					} a[j+1] < rest a[j+1] a j+1 j 1 rest {
						count+= a[j+1];
						a[j+1] = 0;
					} count+= a[j+1] count a[j+1] a j+1 j 1 a[j+1] = 0 a[j+1] a j+1 j 1 0 {
						count+=rest;
						a[j+1] = a[j+1] - rest;
					} count+=rest count rest a[j+1] = a[j+1] - rest a[j+1] a j+1 j 1 a[j+1] - rest a[j+1] a j+1 j 1 rest {
					count+= b[j];
				} count+= b[j] count b[j] b j System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			long[] a = new long[n+1];
			long[] b = new long[n];
			
			for(int i = 0 ; i < n+1; i++ ) {
				a[i] = sc.nextInt();
			}
			for(int i = 0 ; i < n ; i++ ) {
				b[i] = sc.nextInt();
			}
			
			long count = 0;
			for(int j = 0 ; j < n ; j++ ) {

				if ( a[j] < b[j]) {
					count += a[j];
					long rest = b[j] - a[j];
					if ( a[j+1] < rest ) {
						count+= a[j+1];
						a[j+1] = 0;
					}
					else {
						count+=rest;
						a[j+1] = a[j+1] - rest;
					}
				}
				else {
					count+= b[j];
				}
			}
			
			System.out.println(count);
		}
	}
} public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			long[] a = new long[n+1];
			long[] b = new long[n];
			
			for(int i = 0 ; i < n+1; i++ ) {
				a[i] = sc.nextInt();
			}
			for(int i = 0 ; i < n ; i++ ) {
				b[i] = sc.nextInt();
			}
			
			long count = 0;
			for(int j = 0 ; j < n ; j++ ) {

				if ( a[j] < b[j]) {
					count += a[j];
					long rest = b[j] - a[j];
					if ( a[j+1] < rest ) {
						count+= a[j+1];
						a[j+1] = 0;
					}
					else {
						count+=rest;
						a[j+1] = a[j+1] - rest;
					}
				}
				else {
					count+= b[j];
				}
			}
			
			System.out.println(count);
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			long[] a = new long[n+1];
			long[] b = new long[n];
			
			for(int i = 0 ; i < n+1; i++ ) {
				a[i] = sc.nextInt();
			}
			for(int i = 0 ; i < n ; i++ ) {
				b[i] = sc.nextInt();
			}
			
			long count = 0;
			for(int j = 0 ; j < n ; j++ ) {

				if ( a[j] < b[j]) {
					count += a[j];
					long rest = b[j] - a[j];
					if ( a[j+1] < rest ) {
						count+= a[j+1];
						a[j+1] = 0;
					}
					else {
						count+=rest;
						a[j+1] = a[j+1] - rest;
					}
				}
				else {
					count+= b[j];
				}
			}
			
			System.out.println(count);
		}
	}
}