import java.util.Scanner;
class Main{


	static char[][] map;

	static long[][] c;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int[] a = new int[n+1];
		int[] b = new int[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 ans = 0;
		long sup = 0;
		long calc = 0;
		for(int i = 0;i < n;i++){
			calc = a[i];
			if(sup > 0){
				calc -= sup;
			}
			if(calc < 0){				//あまり分で全部倒した時
				sup = b[i];
				ans += a[i];
			}else{
				calc -= b[i];
				if(calc <= 0){			//あまり+i番目の勇者の力で全部倒した時
					sup = -calc;
					ans += a[i];
				}else{
					sup = 0;
					ans += a[i]- calc;
				}
			}
			
			//System.out.println("sup " + sup);
			
		}
		
		if(a[n] - sup > 0){
			ans += sup;
			
		}else{
			ans += a[n];
		}
		System.out.println(ans);
		
		
		
		
		
		
	}
	static boolean check(int[] cc){
		for(int i = 0;i < cc.length-1;i++){
			if(cc[i] > cc[i+1]){
				return false;
			}
		}
		return true;
	}



	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}



class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   end- otherpair.end;
	}








}



 import java.util.Scanner; Scanner java.util class Main{


	static char[][] map;

	static long[][] c;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int[] a = new int[n+1];
		int[] b = new int[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 ans = 0;
		long sup = 0;
		long calc = 0;
		for(int i = 0;i < n;i++){
			calc = a[i];
			if(sup > 0){
				calc -= sup;
			}
			if(calc < 0){				//あまり分で全部倒した時
				sup = b[i];
				ans += a[i];
			}else{
				calc -= b[i];
				if(calc <= 0){			//あまり+i番目の勇者の力で全部倒した時
					sup = -calc;
					ans += a[i];
				}else{
					sup = 0;
					ans += a[i]- calc;
				}
			}
			
			//System.out.println("sup " + sup);
			
		}
		
		if(a[n] - sup > 0){
			ans += sup;
			
		}else{
			ans += a[n];
		}
		System.out.println(ans);
		
		
		
		
		
		
	}
	static boolean check(int[] cc){
		for(int i = 0;i < cc.length-1;i++){
			if(cc[i] > cc[i+1]){
				return false;
			}
		}
		return true;
	}



	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




} Main static char[][] map; map static long[][] c; c public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int[] a = new int[n+1];
		int[] b = new int[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 ans = 0;
		long sup = 0;
		long calc = 0;
		for(int i = 0;i < n;i++){
			calc = a[i];
			if(sup > 0){
				calc -= sup;
			}
			if(calc < 0){				//あまり分で全部倒した時
				sup = b[i];
				ans += a[i];
			}else{
				calc -= b[i];
				if(calc <= 0){			//あまり+i番目の勇者の力で全部倒した時
					sup = -calc;
					ans += a[i];
				}else{
					sup = 0;
					ans += a[i]- calc;
				}
			}
			
			//System.out.println("sup " + sup);
			
		}
		
		if(a[n] - sup > 0){
			ans += sup;
			
		}else{
			ans += a[n];
		}
		System.out.println(ans);
		
		
		
		
		
		
	} main {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int[] a = new int[n+1];
		int[] b = new int[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 ans = 0;
		long sup = 0;
		long calc = 0;
		for(int i = 0;i < n;i++){
			calc = a[i];
			if(sup > 0){
				calc -= sup;
			}
			if(calc < 0){				//あまり分で全部倒した時
				sup = b[i];
				ans += a[i];
			}else{
				calc -= b[i];
				if(calc <= 0){			//あまり+i番目の勇者の力で全部倒した時
					sup = -calc;
					ans += a[i];
				}else{
					sup = 0;
					ans += a[i]- calc;
				}
			}
			
			//System.out.println("sup " + sup);
			
		}
		
		if(a[n] - sup > 0){
			ans += sup;
			
		}else{
			ans += a[n];
		}
		System.out.println(ans);
		
		
		
		
		
		
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt 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+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 ans = 0; ans 0 long sup = 0; sup 0 long calc = 0; calc 0 for(int i = 0;i < n;i++){
			calc = a[i];
			if(sup > 0){
				calc -= sup;
			}
			if(calc < 0){				//あまり分で全部倒した時
				sup = b[i];
				ans += a[i];
			}else{
				calc -= b[i];
				if(calc <= 0){			//あまり+i番目の勇者の力で全部倒した時
					sup = -calc;
					ans += a[i];
				}else{
					sup = 0;
					ans += a[i]- calc;
				}
			}
			
			//System.out.println("sup " + sup);
			
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			calc = a[i];
			if(sup > 0){
				calc -= sup;
			}
			if(calc < 0){				//あまり分で全部倒した時
				sup = b[i];
				ans += a[i];
			}else{
				calc -= b[i];
				if(calc <= 0){			//あまり+i番目の勇者の力で全部倒した時
					sup = -calc;
					ans += a[i];
				}else{
					sup = 0;
					ans += a[i]- calc;
				}
			}
			
			//System.out.println("sup " + sup);
			
		} {
			calc = a[i];
			if(sup > 0){
				calc -= sup;
			}
			if(calc < 0){				//あまり分で全部倒した時
				sup = b[i];
				ans += a[i];
			}else{
				calc -= b[i];
				if(calc <= 0){			//あまり+i番目の勇者の力で全部倒した時
					sup = -calc;
					ans += a[i];
				}else{
					sup = 0;
					ans += a[i]- calc;
				}
			}
			
			//System.out.println("sup " + sup);
			
		} calc = a[i] calc a[i] a i if(sup > 0){
				calc -= sup;
			} sup > 0 sup 0 {
				calc -= sup;
			} calc -= sup calc sup if(calc < 0){				//あまり分で全部倒した時
				sup = b[i];
				ans += a[i];
			}else{
				calc -= b[i];
				if(calc <= 0){			//あまり+i番目の勇者の力で全部倒した時
					sup = -calc;
					ans += a[i];
				}else{
					sup = 0;
					ans += a[i]- calc;
				}
			} calc < 0 calc 0 {				//あまり分で全部倒した時
				sup = b[i];
				ans += a[i];
			} sup = b[i] sup b[i] b i ans += a[i] ans a[i] a i {
				calc -= b[i];
				if(calc <= 0){			//あまり+i番目の勇者の力で全部倒した時
					sup = -calc;
					ans += a[i];
				}else{
					sup = 0;
					ans += a[i]- calc;
				}
			} calc -= b[i] calc b[i] b i if(calc <= 0){			//あまり+i番目の勇者の力で全部倒した時
					sup = -calc;
					ans += a[i];
				}else{
					sup = 0;
					ans += a[i]- calc;
				} calc <= 0 calc 0 {			//あまり+i番目の勇者の力で全部倒した時
					sup = -calc;
					ans += a[i];
				} sup = -calc sup -calc calc ans += a[i] ans a[i] a i {
					sup = 0;
					ans += a[i]- calc;
				} sup = 0 sup 0 ans += a[i]- calc ans a[i]- calc a[i] a i calc if(a[n] - sup > 0){
			ans += sup;
			
		}else{
			ans += a[n];
		} a[n] - sup > 0 a[n] - sup a[n] a n sup 0 {
			ans += sup;
			
		} ans += sup ans sup {
			ans += a[n];
		} ans += a[n] ans a[n] a n System.out.println(ans) System.out.println System.out System System.out ans String[] args args static boolean check(int[] cc){
		for(int i = 0;i < cc.length-1;i++){
			if(cc[i] > cc[i+1]){
				return false;
			}
		}
		return true;
	} check {
		for(int i = 0;i < cc.length-1;i++){
			if(cc[i] > cc[i+1]){
				return false;
			}
		}
		return true;
	} for(int i = 0;i < cc.length-1;i++){
			if(cc[i] > cc[i+1]){
				return false;
			}
		} int i = 0; int i = 0; i 0 i < cc.length-1 i cc.length-1 cc.length cc cc.length 1 i++ i++ i {
			if(cc[i] > cc[i+1]){
				return false;
			}
		} {
			if(cc[i] > cc[i+1]){
				return false;
			}
		} if(cc[i] > cc[i+1]){
				return false;
			} cc[i] > cc[i+1] cc[i] cc i cc[i+1] cc i+1 i 1 {
				return false;
			} return false; false return true; true int[] cc cc static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	} gcd {				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	} if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		} b == 0 b 0 {
			return a;
		} return a; a {
			return gcd(b, a%b);
		} return gcd(b, a%b); gcd(b, a%b) gcd b a%b a b int a a int b b static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	} gcd {
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	} if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		} b == 0 b 0 {
			return a;
		} return a; a {
			return gcd(b, a%b);
		} return gcd(b, a%b); gcd(b, a%b) gcd b a%b a b long a a long b b static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	} lcm {
		long g = gcd(a,b);
		return a/g*b;
	} long g = gcd(a,b); g gcd(a,b) gcd a b return a/g*b; a/g*b a/g a g b long a a long b b class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   end- otherpair.end;
	}








} Pair int from; from int end; end @Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   end- otherpair.end;
	} compareTo {
		Pair otherpair = (Pair)other;

		return   end- otherpair.end;
	} Pair otherpair = (Pair)other; otherpair (Pair)other return   end- otherpair.end; end- otherpair.end end otherpair.end otherpair otherpair.end Object other other Comparable
import java.util.Scanner;
class Main{


	static char[][] map;

	static long[][] c;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int[] a = new int[n+1];
		int[] b = new int[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 ans = 0;
		long sup = 0;
		long calc = 0;
		for(int i = 0;i < n;i++){
			calc = a[i];
			if(sup > 0){
				calc -= sup;
			}
			if(calc < 0){				//あまり分で全部倒した時
				sup = b[i];
				ans += a[i];
			}else{
				calc -= b[i];
				if(calc <= 0){			//あまり+i番目の勇者の力で全部倒した時
					sup = -calc;
					ans += a[i];
				}else{
					sup = 0;
					ans += a[i]- calc;
				}
			}
			
			//System.out.println("sup " + sup);
			
		}
		
		if(a[n] - sup > 0){
			ans += sup;
			
		}else{
			ans += a[n];
		}
		System.out.println(ans);
		
		
		
		
		
		
	}
	static boolean check(int[] cc){
		for(int i = 0;i < cc.length-1;i++){
			if(cc[i] > cc[i+1]){
				return false;
			}
		}
		return true;
	}



	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}



class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   end- otherpair.end;
	}








}




