import java.util.Scanner;

public class Main {
	public static void solution(int [] arr1, int [] arr2) {
		long monster = 0;
		for(int i=0;i<arr2.length;i++) {
			if(arr1[i]>=arr2[i]) {
				monster+=arr2[i];
			}
			else {
				if(arr1[i]+arr1[i+1]>=arr2[i]) {
					monster+=arr2[i];
					arr1[i+1]-=arr2[i]-arr1[i];
				}
				else {
					monster+=arr1[i]+arr1[i+1];
					arr1[i+1]=0;
				}
			}
		}
		System.out.println(monster);
	}
	
	
	public static void main(String args []) {
		Scanner obj = new Scanner(System.in);
		int n = obj.nextInt();
		int a [] = new int [n+1];
		int b [] = new int [n];
		for(int i=0;i<a.length;i++) {
			a[i]= obj.nextInt();
		}
		for(int i=0;i<b.length;i++) {
			b[i]= obj.nextInt();
		}
		solution(a,b);
		
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void solution(int [] arr1, int [] arr2) {
		long monster = 0;
		for(int i=0;i<arr2.length;i++) {
			if(arr1[i]>=arr2[i]) {
				monster+=arr2[i];
			}
			else {
				if(arr1[i]+arr1[i+1]>=arr2[i]) {
					monster+=arr2[i];
					arr1[i+1]-=arr2[i]-arr1[i];
				}
				else {
					monster+=arr1[i]+arr1[i+1];
					arr1[i+1]=0;
				}
			}
		}
		System.out.println(monster);
	}
	
	
	public static void main(String args []) {
		Scanner obj = new Scanner(System.in);
		int n = obj.nextInt();
		int a [] = new int [n+1];
		int b [] = new int [n];
		for(int i=0;i<a.length;i++) {
			a[i]= obj.nextInt();
		}
		for(int i=0;i<b.length;i++) {
			b[i]= obj.nextInt();
		}
		solution(a,b);
		
	}
} Main public static void solution(int [] arr1, int [] arr2) {
		long monster = 0;
		for(int i=0;i<arr2.length;i++) {
			if(arr1[i]>=arr2[i]) {
				monster+=arr2[i];
			}
			else {
				if(arr1[i]+arr1[i+1]>=arr2[i]) {
					monster+=arr2[i];
					arr1[i+1]-=arr2[i]-arr1[i];
				}
				else {
					monster+=arr1[i]+arr1[i+1];
					arr1[i+1]=0;
				}
			}
		}
		System.out.println(monster);
	} solution {
		long monster = 0;
		for(int i=0;i<arr2.length;i++) {
			if(arr1[i]>=arr2[i]) {
				monster+=arr2[i];
			}
			else {
				if(arr1[i]+arr1[i+1]>=arr2[i]) {
					monster+=arr2[i];
					arr1[i+1]-=arr2[i]-arr1[i];
				}
				else {
					monster+=arr1[i]+arr1[i+1];
					arr1[i+1]=0;
				}
			}
		}
		System.out.println(monster);
	} long monster = 0; monster 0 for(int i=0;i<arr2.length;i++) {
			if(arr1[i]>=arr2[i]) {
				monster+=arr2[i];
			}
			else {
				if(arr1[i]+arr1[i+1]>=arr2[i]) {
					monster+=arr2[i];
					arr1[i+1]-=arr2[i]-arr1[i];
				}
				else {
					monster+=arr1[i]+arr1[i+1];
					arr1[i+1]=0;
				}
			}
		} int i=0; int i=0; i 0 i<arr2.length i arr2.length arr2 arr2.length i++ i++ i {
			if(arr1[i]>=arr2[i]) {
				monster+=arr2[i];
			}
			else {
				if(arr1[i]+arr1[i+1]>=arr2[i]) {
					monster+=arr2[i];
					arr1[i+1]-=arr2[i]-arr1[i];
				}
				else {
					monster+=arr1[i]+arr1[i+1];
					arr1[i+1]=0;
				}
			}
		} {
			if(arr1[i]>=arr2[i]) {
				monster+=arr2[i];
			}
			else {
				if(arr1[i]+arr1[i+1]>=arr2[i]) {
					monster+=arr2[i];
					arr1[i+1]-=arr2[i]-arr1[i];
				}
				else {
					monster+=arr1[i]+arr1[i+1];
					arr1[i+1]=0;
				}
			}
		} if(arr1[i]>=arr2[i]) {
				monster+=arr2[i];
			}
			else {
				if(arr1[i]+arr1[i+1]>=arr2[i]) {
					monster+=arr2[i];
					arr1[i+1]-=arr2[i]-arr1[i];
				}
				else {
					monster+=arr1[i]+arr1[i+1];
					arr1[i+1]=0;
				}
			} arr1[i]>=arr2[i] arr1[i] arr1 i arr2[i] arr2 i {
				monster+=arr2[i];
			} monster+=arr2[i] monster arr2[i] arr2 i {
				if(arr1[i]+arr1[i+1]>=arr2[i]) {
					monster+=arr2[i];
					arr1[i+1]-=arr2[i]-arr1[i];
				}
				else {
					monster+=arr1[i]+arr1[i+1];
					arr1[i+1]=0;
				}
			} if(arr1[i]+arr1[i+1]>=arr2[i]) {
					monster+=arr2[i];
					arr1[i+1]-=arr2[i]-arr1[i];
				}
				else {
					monster+=arr1[i]+arr1[i+1];
					arr1[i+1]=0;
				} arr1[i]+arr1[i+1]>=arr2[i] arr1[i]+arr1[i+1] arr1[i] arr1 i arr1[i+1] arr1 i+1 i 1 arr2[i] arr2 i {
					monster+=arr2[i];
					arr1[i+1]-=arr2[i]-arr1[i];
				} monster+=arr2[i] monster arr2[i] arr2 i arr1[i+1]-=arr2[i]-arr1[i] arr1[i+1] arr1 i+1 i 1 arr2[i]-arr1[i] arr2[i] arr2 i arr1[i] arr1 i {
					monster+=arr1[i]+arr1[i+1];
					arr1[i+1]=0;
				} monster+=arr1[i]+arr1[i+1] monster arr1[i]+arr1[i+1] arr1[i] arr1 i arr1[i+1] arr1 i+1 i 1 arr1[i+1]=0 arr1[i+1] arr1 i+1 i 1 0 System.out.println(monster) System.out.println System.out System System.out monster int [] arr1 arr1 int [] arr2 arr2 public static void main(String args []) {
		Scanner obj = new Scanner(System.in);
		int n = obj.nextInt();
		int a [] = new int [n+1];
		int b [] = new int [n];
		for(int i=0;i<a.length;i++) {
			a[i]= obj.nextInt();
		}
		for(int i=0;i<b.length;i++) {
			b[i]= obj.nextInt();
		}
		solution(a,b);
		
	} main {
		Scanner obj = new Scanner(System.in);
		int n = obj.nextInt();
		int a [] = new int [n+1];
		int b [] = new int [n];
		for(int i=0;i<a.length;i++) {
			a[i]= obj.nextInt();
		}
		for(int i=0;i<b.length;i++) {
			b[i]= obj.nextInt();
		}
		solution(a,b);
		
	} Scanner obj = new Scanner(System.in); obj new Scanner(System.in) int n = obj.nextInt(); n obj.nextInt() obj.nextInt obj 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<a.length;i++) {
			a[i]= obj.nextInt();
		} int i=0; int i=0; i 0 i<a.length i a.length a a.length i++ i++ i {
			a[i]= obj.nextInt();
		} {
			a[i]= obj.nextInt();
		} a[i]= obj.nextInt() a[i] a i obj.nextInt() obj.nextInt obj for(int i=0;i<b.length;i++) {
			b[i]= obj.nextInt();
		} int i=0; int i=0; i 0 i<b.length i b.length b b.length i++ i++ i {
			b[i]= obj.nextInt();
		} {
			b[i]= obj.nextInt();
		} b[i]= obj.nextInt() b[i] b i obj.nextInt() obj.nextInt obj solution(a,b) solution a b String args [] args public class Main {
	public static void solution(int [] arr1, int [] arr2) {
		long monster = 0;
		for(int i=0;i<arr2.length;i++) {
			if(arr1[i]>=arr2[i]) {
				monster+=arr2[i];
			}
			else {
				if(arr1[i]+arr1[i+1]>=arr2[i]) {
					monster+=arr2[i];
					arr1[i+1]-=arr2[i]-arr1[i];
				}
				else {
					monster+=arr1[i]+arr1[i+1];
					arr1[i+1]=0;
				}
			}
		}
		System.out.println(monster);
	}
	
	
	public static void main(String args []) {
		Scanner obj = new Scanner(System.in);
		int n = obj.nextInt();
		int a [] = new int [n+1];
		int b [] = new int [n];
		for(int i=0;i<a.length;i++) {
			a[i]= obj.nextInt();
		}
		for(int i=0;i<b.length;i++) {
			b[i]= obj.nextInt();
		}
		solution(a,b);
		
	}
} public class Main {
	public static void solution(int [] arr1, int [] arr2) {
		long monster = 0;
		for(int i=0;i<arr2.length;i++) {
			if(arr1[i]>=arr2[i]) {
				monster+=arr2[i];
			}
			else {
				if(arr1[i]+arr1[i+1]>=arr2[i]) {
					monster+=arr2[i];
					arr1[i+1]-=arr2[i]-arr1[i];
				}
				else {
					monster+=arr1[i]+arr1[i+1];
					arr1[i+1]=0;
				}
			}
		}
		System.out.println(monster);
	}
	
	
	public static void main(String args []) {
		Scanner obj = new Scanner(System.in);
		int n = obj.nextInt();
		int a [] = new int [n+1];
		int b [] = new int [n];
		for(int i=0;i<a.length;i++) {
			a[i]= obj.nextInt();
		}
		for(int i=0;i<b.length;i++) {
			b[i]= obj.nextInt();
		}
		solution(a,b);
		
	}
} Main
import java.util.Scanner;

public class Main {
	public static void solution(int [] arr1, int [] arr2) {
		long monster = 0;
		for(int i=0;i<arr2.length;i++) {
			if(arr1[i]>=arr2[i]) {
				monster+=arr2[i];
			}
			else {
				if(arr1[i]+arr1[i+1]>=arr2[i]) {
					monster+=arr2[i];
					arr1[i+1]-=arr2[i]-arr1[i];
				}
				else {
					monster+=arr1[i]+arr1[i+1];
					arr1[i+1]=0;
				}
			}
		}
		System.out.println(monster);
	}
	
	
	public static void main(String args []) {
		Scanner obj = new Scanner(System.in);
		int n = obj.nextInt();
		int a [] = new int [n+1];
		int b [] = new int [n];
		for(int i=0;i<a.length;i++) {
			a[i]= obj.nextInt();
		}
		for(int i=0;i<b.length;i++) {
			b[i]= obj.nextInt();
		}
		solution(a,b);
		
	}
}
