import java.util.*;
import java.io.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		HashMap hs = new HashMap();
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n + 1];
		int[] b = new int[n];
		for(int i = 0 ; i <= n ; i++){
			a[i] = Integer.parseInt(sc.next());
		}
		for(int i = 0 ; i < n ; i++){
			b[i] = Integer.parseInt(sc.next());
		}
		sc.close();
		long yono = 0;
		for(int i = 0 ; i < n ; i++){
			if(a[i] >= b[i]){
				a[i] -= b[i];
				yono += b[i];
			}else{
				b[i] -= a[i];
				yono += a[i];
				yono += Math.min(b[i] , a[i + 1]);
				a[i + 1] -= Math.min(a[i + 1] , b[i]);
			}
		}
		ou.print(yono + "\n");
		ou.flush();
	}
} import java.util.*; util.* java import java.io.*; io.* java public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		HashMap hs = new HashMap();
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n + 1];
		int[] b = new int[n];
		for(int i = 0 ; i <= n ; i++){
			a[i] = Integer.parseInt(sc.next());
		}
		for(int i = 0 ; i < n ; i++){
			b[i] = Integer.parseInt(sc.next());
		}
		sc.close();
		long yono = 0;
		for(int i = 0 ; i < n ; i++){
			if(a[i] >= b[i]){
				a[i] -= b[i];
				yono += b[i];
			}else{
				b[i] -= a[i];
				yono += a[i];
				yono += Math.min(b[i] , a[i + 1]);
				a[i + 1] -= Math.min(a[i + 1] , b[i]);
			}
		}
		ou.print(yono + "\n");
		ou.flush();
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		HashMap hs = new HashMap();
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n + 1];
		int[] b = new int[n];
		for(int i = 0 ; i <= n ; i++){
			a[i] = Integer.parseInt(sc.next());
		}
		for(int i = 0 ; i < n ; i++){
			b[i] = Integer.parseInt(sc.next());
		}
		sc.close();
		long yono = 0;
		for(int i = 0 ; i < n ; i++){
			if(a[i] >= b[i]){
				a[i] -= b[i];
				yono += b[i];
			}else{
				b[i] -= a[i];
				yono += a[i];
				yono += Math.min(b[i] , a[i + 1]);
				a[i + 1] -= Math.min(a[i + 1] , b[i]);
			}
		}
		ou.print(yono + "\n");
		ou.flush();
	} main {
		Scanner sc = new Scanner(System.in);
		HashMap hs = new HashMap();
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n + 1];
		int[] b = new int[n];
		for(int i = 0 ; i <= n ; i++){
			a[i] = Integer.parseInt(sc.next());
		}
		for(int i = 0 ; i < n ; i++){
			b[i] = Integer.parseInt(sc.next());
		}
		sc.close();
		long yono = 0;
		for(int i = 0 ; i < n ; i++){
			if(a[i] >= b[i]){
				a[i] -= b[i];
				yono += b[i];
			}else{
				b[i] -= a[i];
				yono += a[i];
				yono += Math.min(b[i] , a[i + 1]);
				a[i + 1] -= Math.min(a[i + 1] , b[i]);
			}
		}
		ou.print(yono + "\n");
		ou.flush();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) HashMap hs = new HashMap(); hs new HashMap() PrintWriter ou = new PrintWriter(System.out); ou new PrintWriter(System.out) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc 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 ; i++){
			a[i] = Integer.parseInt(sc.next());
		} int i = 0 ; int i = 0 ; i 0 i <= n i n i++ i++ i {
			a[i] = Integer.parseInt(sc.next());
		} {
			a[i] = Integer.parseInt(sc.next());
		} a[i] = Integer.parseInt(sc.next()) a[i] a i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc for(int i = 0 ; i < n ; i++){
			b[i] = Integer.parseInt(sc.next());
		} int i = 0 ; int i = 0 ; i 0 i < n i n i++ i++ i {
			b[i] = Integer.parseInt(sc.next());
		} {
			b[i] = Integer.parseInt(sc.next());
		} b[i] = Integer.parseInt(sc.next()) b[i] b i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc sc.close() sc.close sc long yono = 0; yono 0 for(int i = 0 ; i < n ; i++){
			if(a[i] >= b[i]){
				a[i] -= b[i];
				yono += b[i];
			}else{
				b[i] -= a[i];
				yono += a[i];
				yono += Math.min(b[i] , a[i + 1]);
				a[i + 1] -= Math.min(a[i + 1] , b[i]);
			}
		} int i = 0 ; int i = 0 ; i 0 i < n i n i++ i++ i {
			if(a[i] >= b[i]){
				a[i] -= b[i];
				yono += b[i];
			}else{
				b[i] -= a[i];
				yono += a[i];
				yono += Math.min(b[i] , a[i + 1]);
				a[i + 1] -= Math.min(a[i + 1] , b[i]);
			}
		} {
			if(a[i] >= b[i]){
				a[i] -= b[i];
				yono += b[i];
			}else{
				b[i] -= a[i];
				yono += a[i];
				yono += Math.min(b[i] , a[i + 1]);
				a[i + 1] -= Math.min(a[i + 1] , b[i]);
			}
		} if(a[i] >= b[i]){
				a[i] -= b[i];
				yono += b[i];
			}else{
				b[i] -= a[i];
				yono += a[i];
				yono += Math.min(b[i] , a[i + 1]);
				a[i + 1] -= Math.min(a[i + 1] , b[i]);
			} a[i] >= b[i] a[i] a i b[i] b i {
				a[i] -= b[i];
				yono += b[i];
			} a[i] -= b[i] a[i] a i b[i] b i yono += b[i] yono b[i] b i {
				b[i] -= a[i];
				yono += a[i];
				yono += Math.min(b[i] , a[i + 1]);
				a[i + 1] -= Math.min(a[i + 1] , b[i]);
			} b[i] -= a[i] b[i] b i a[i] a i yono += a[i] yono a[i] a i yono += Math.min(b[i] , a[i + 1]) yono Math.min(b[i] , a[i + 1]) Math.min Math b[i] b i a[i + 1] a i + 1 i 1 a[i + 1] -= Math.min(a[i + 1] , b[i]) a[i + 1] a i + 1 i 1 Math.min(a[i + 1] , b[i]) Math.min Math a[i + 1] a i + 1 i 1 b[i] b i ou.print(yono + "\n") ou.print ou yono + "\n" yono "\n" ou.flush() ou.flush ou String[] args args public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		HashMap hs = new HashMap();
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n + 1];
		int[] b = new int[n];
		for(int i = 0 ; i <= n ; i++){
			a[i] = Integer.parseInt(sc.next());
		}
		for(int i = 0 ; i < n ; i++){
			b[i] = Integer.parseInt(sc.next());
		}
		sc.close();
		long yono = 0;
		for(int i = 0 ; i < n ; i++){
			if(a[i] >= b[i]){
				a[i] -= b[i];
				yono += b[i];
			}else{
				b[i] -= a[i];
				yono += a[i];
				yono += Math.min(b[i] , a[i + 1]);
				a[i + 1] -= Math.min(a[i + 1] , b[i]);
			}
		}
		ou.print(yono + "\n");
		ou.flush();
	}
} public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		HashMap hs = new HashMap();
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n + 1];
		int[] b = new int[n];
		for(int i = 0 ; i <= n ; i++){
			a[i] = Integer.parseInt(sc.next());
		}
		for(int i = 0 ; i < n ; i++){
			b[i] = Integer.parseInt(sc.next());
		}
		sc.close();
		long yono = 0;
		for(int i = 0 ; i < n ; i++){
			if(a[i] >= b[i]){
				a[i] -= b[i];
				yono += b[i];
			}else{
				b[i] -= a[i];
				yono += a[i];
				yono += Math.min(b[i] , a[i + 1]);
				a[i + 1] -= Math.min(a[i + 1] , b[i]);
			}
		}
		ou.print(yono + "\n");
		ou.flush();
	}
} Main
import java.util.*;
import java.io.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		HashMap hs = new HashMap();
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n + 1];
		int[] b = new int[n];
		for(int i = 0 ; i <= n ; i++){
			a[i] = Integer.parseInt(sc.next());
		}
		for(int i = 0 ; i < n ; i++){
			b[i] = Integer.parseInt(sc.next());
		}
		sc.close();
		long yono = 0;
		for(int i = 0 ; i < n ; i++){
			if(a[i] >= b[i]){
				a[i] -= b[i];
				yono += b[i];
			}else{
				b[i] -= a[i];
				yono += a[i];
				yono += Math.min(b[i] , a[i + 1]);
				a[i + 1] -= Math.min(a[i + 1] , b[i]);
			}
		}
		ou.print(yono + "\n");
		ou.flush();
	}
}