import java.util.*;
class Main{
	static Scanner input = new Scanner(System.in);
	public static void main(String[] args){
		int n = input.nextInt();
		long A[] = new long[n+1];
		long B[] = new long[n+1];
		for(int i= 0 ;i < n+1 ; i++)
			A[i] = input.nextInt();
		for(int i = 0 ;i < n; i++)
			B[i] = input.nextInt();
		long ans = 0 ,left = 0;
		for(int i = 0 ;i < n+1 ; i++){
			if(A[i] > left + B[i]){
				ans += left + B[i];
				left = 0;
			}
			else if(A[i] < left){
				ans += A[i];
				left = B[i];
			}
			else{
				ans += A[i];
				left = B[i] - A[i] + left;
			}
		}
		System.out.println(ans);
	}		
} import java.util.*; util.* java class Main{
	static Scanner input = new Scanner(System.in);
	public static void main(String[] args){
		int n = input.nextInt();
		long A[] = new long[n+1];
		long B[] = new long[n+1];
		for(int i= 0 ;i < n+1 ; i++)
			A[i] = input.nextInt();
		for(int i = 0 ;i < n; i++)
			B[i] = input.nextInt();
		long ans = 0 ,left = 0;
		for(int i = 0 ;i < n+1 ; i++){
			if(A[i] > left + B[i]){
				ans += left + B[i];
				left = 0;
			}
			else if(A[i] < left){
				ans += A[i];
				left = B[i];
			}
			else{
				ans += A[i];
				left = B[i] - A[i] + left;
			}
		}
		System.out.println(ans);
	}		
} Main static Scanner input = new Scanner(System.in); input new Scanner(System.in) public static void main(String[] args){
		int n = input.nextInt();
		long A[] = new long[n+1];
		long B[] = new long[n+1];
		for(int i= 0 ;i < n+1 ; i++)
			A[i] = input.nextInt();
		for(int i = 0 ;i < n; i++)
			B[i] = input.nextInt();
		long ans = 0 ,left = 0;
		for(int i = 0 ;i < n+1 ; i++){
			if(A[i] > left + B[i]){
				ans += left + B[i];
				left = 0;
			}
			else if(A[i] < left){
				ans += A[i];
				left = B[i];
			}
			else{
				ans += A[i];
				left = B[i] - A[i] + left;
			}
		}
		System.out.println(ans);
	} main {
		int n = input.nextInt();
		long A[] = new long[n+1];
		long B[] = new long[n+1];
		for(int i= 0 ;i < n+1 ; i++)
			A[i] = input.nextInt();
		for(int i = 0 ;i < n; i++)
			B[i] = input.nextInt();
		long ans = 0 ,left = 0;
		for(int i = 0 ;i < n+1 ; i++){
			if(A[i] > left + B[i]){
				ans += left + B[i];
				left = 0;
			}
			else if(A[i] < left){
				ans += A[i];
				left = B[i];
			}
			else{
				ans += A[i];
				left = B[i] - A[i] + left;
			}
		}
		System.out.println(ans);
	} int n = input.nextInt(); n input.nextInt() input.nextInt input long A[] = new long[n+1]; A new long[n+1] n+1 n 1 long B[] = new long[n+1]; B new long[n+1] n+1 n 1 for(int i= 0 ;i < n+1 ; i++)
			A[i] = input.nextInt(); int i= 0 ; int i= 0 ; i 0 i < n+1 i n+1 n 1 i++ i++ i A[i] = input.nextInt(); A[i] = input.nextInt() A[i] A i input.nextInt() input.nextInt input for(int i = 0 ;i < n; i++)
			B[i] = input.nextInt(); int i = 0 ; int i = 0 ; i 0 i < n i n i++ i++ i B[i] = input.nextInt(); B[i] = input.nextInt() B[i] B i input.nextInt() input.nextInt input long ans = 0 ans 0 left = 0; left 0 for(int i = 0 ;i < n+1 ; i++){
			if(A[i] > left + B[i]){
				ans += left + B[i];
				left = 0;
			}
			else if(A[i] < left){
				ans += A[i];
				left = B[i];
			}
			else{
				ans += A[i];
				left = B[i] - A[i] + left;
			}
		} int i = 0 ; int i = 0 ; i 0 i < n+1 i n+1 n 1 i++ i++ i {
			if(A[i] > left + B[i]){
				ans += left + B[i];
				left = 0;
			}
			else if(A[i] < left){
				ans += A[i];
				left = B[i];
			}
			else{
				ans += A[i];
				left = B[i] - A[i] + left;
			}
		} {
			if(A[i] > left + B[i]){
				ans += left + B[i];
				left = 0;
			}
			else if(A[i] < left){
				ans += A[i];
				left = B[i];
			}
			else{
				ans += A[i];
				left = B[i] - A[i] + left;
			}
		} if(A[i] > left + B[i]){
				ans += left + B[i];
				left = 0;
			}
			else if(A[i] < left){
				ans += A[i];
				left = B[i];
			}
			else{
				ans += A[i];
				left = B[i] - A[i] + left;
			} A[i] > left + B[i] A[i] A i left + B[i] left B[i] B i {
				ans += left + B[i];
				left = 0;
			} ans += left + B[i] ans left + B[i] left B[i] B i left = 0 left 0 if(A[i] < left){
				ans += A[i];
				left = B[i];
			}
			else{
				ans += A[i];
				left = B[i] - A[i] + left;
			} A[i] < left A[i] A i left {
				ans += A[i];
				left = B[i];
			} ans += A[i] ans A[i] A i left = B[i] left B[i] B i {
				ans += A[i];
				left = B[i] - A[i] + left;
			} ans += A[i] ans A[i] A i left = B[i] - A[i] + left left B[i] - A[i] + left B[i] - A[i] B[i] B i A[i] A i left System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*;
class Main{
	static Scanner input = new Scanner(System.in);
	public static void main(String[] args){
		int n = input.nextInt();
		long A[] = new long[n+1];
		long B[] = new long[n+1];
		for(int i= 0 ;i < n+1 ; i++)
			A[i] = input.nextInt();
		for(int i = 0 ;i < n; i++)
			B[i] = input.nextInt();
		long ans = 0 ,left = 0;
		for(int i = 0 ;i < n+1 ; i++){
			if(A[i] > left + B[i]){
				ans += left + B[i];
				left = 0;
			}
			else if(A[i] < left){
				ans += A[i];
				left = B[i];
			}
			else{
				ans += A[i];
				left = B[i] - A[i] + left;
			}
		}
		System.out.println(ans);
	}		
}