import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);		
		int N = in.nextInt();
        long mo[] = new long[N+1];
      
      for(int i = 0;i < N+1;i++){
      	mo[i] = in.nextInt(); 
      }
      
      long sum = 0;
      long yu = 0;
      
      for(int i =0;i < N;i++){
		yu = in.nextInt(); 
        
        if(yu>mo[i]){
        	sum += mo[i];
            yu  -= mo[i]; 
        	sum += Math.min(mo[i+1],yu);
            mo[i+1] = Math.max(0,mo[i+1]-yu); 
        }else{
          sum +=yu;
        }
      }
       System.out.print(sum); 
      }
	} import java.util.*; util.* java public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);		
		int N = in.nextInt();
        long mo[] = new long[N+1];
      
      for(int i = 0;i < N+1;i++){
      	mo[i] = in.nextInt(); 
      }
      
      long sum = 0;
      long yu = 0;
      
      for(int i =0;i < N;i++){
		yu = in.nextInt(); 
        
        if(yu>mo[i]){
        	sum += mo[i];
            yu  -= mo[i]; 
        	sum += Math.min(mo[i+1],yu);
            mo[i+1] = Math.max(0,mo[i+1]-yu); 
        }else{
          sum +=yu;
        }
      }
       System.out.print(sum); 
      }
	} Main public static void main (String[] args) {
		Scanner in = new Scanner(System.in);		
		int N = in.nextInt();
        long mo[] = new long[N+1];
      
      for(int i = 0;i < N+1;i++){
      	mo[i] = in.nextInt(); 
      }
      
      long sum = 0;
      long yu = 0;
      
      for(int i =0;i < N;i++){
		yu = in.nextInt(); 
        
        if(yu>mo[i]){
        	sum += mo[i];
            yu  -= mo[i]; 
        	sum += Math.min(mo[i+1],yu);
            mo[i+1] = Math.max(0,mo[i+1]-yu); 
        }else{
          sum +=yu;
        }
      }
       System.out.print(sum); 
      } main {
		Scanner in = new Scanner(System.in);		
		int N = in.nextInt();
        long mo[] = new long[N+1];
      
      for(int i = 0;i < N+1;i++){
      	mo[i] = in.nextInt(); 
      }
      
      long sum = 0;
      long yu = 0;
      
      for(int i =0;i < N;i++){
		yu = in.nextInt(); 
        
        if(yu>mo[i]){
        	sum += mo[i];
            yu  -= mo[i]; 
        	sum += Math.min(mo[i+1],yu);
            mo[i+1] = Math.max(0,mo[i+1]-yu); 
        }else{
          sum +=yu;
        }
      }
       System.out.print(sum); 
      } Scanner in = new Scanner(System.in); in new Scanner(System.in) int N = in.nextInt(); N in.nextInt() in.nextInt in long mo[] = new long[N+1]; mo new long[N+1] N+1 N 1 for(int i = 0;i < N+1;i++){
      	mo[i] = in.nextInt(); 
      } int i = 0; int i = 0; i 0 i < N+1 i N+1 N 1 i++ i++ i {
      	mo[i] = in.nextInt(); 
      } {
      	mo[i] = in.nextInt(); 
      } mo[i] = in.nextInt() mo[i] mo i in.nextInt() in.nextInt in long sum = 0; sum 0 long yu = 0; yu 0 for(int i =0;i < N;i++){
		yu = in.nextInt(); 
        
        if(yu>mo[i]){
        	sum += mo[i];
            yu  -= mo[i]; 
        	sum += Math.min(mo[i+1],yu);
            mo[i+1] = Math.max(0,mo[i+1]-yu); 
        }else{
          sum +=yu;
        }
      } int i =0; int i =0; i 0 i < N i N i++ i++ i {
		yu = in.nextInt(); 
        
        if(yu>mo[i]){
        	sum += mo[i];
            yu  -= mo[i]; 
        	sum += Math.min(mo[i+1],yu);
            mo[i+1] = Math.max(0,mo[i+1]-yu); 
        }else{
          sum +=yu;
        }
      } {
		yu = in.nextInt(); 
        
        if(yu>mo[i]){
        	sum += mo[i];
            yu  -= mo[i]; 
        	sum += Math.min(mo[i+1],yu);
            mo[i+1] = Math.max(0,mo[i+1]-yu); 
        }else{
          sum +=yu;
        }
      } yu = in.nextInt() yu in.nextInt() in.nextInt in if(yu>mo[i]){
        	sum += mo[i];
            yu  -= mo[i]; 
        	sum += Math.min(mo[i+1],yu);
            mo[i+1] = Math.max(0,mo[i+1]-yu); 
        }else{
          sum +=yu;
        } yu>mo[i] yu mo[i] mo i {
        	sum += mo[i];
            yu  -= mo[i]; 
        	sum += Math.min(mo[i+1],yu);
            mo[i+1] = Math.max(0,mo[i+1]-yu); 
        } sum += mo[i] sum mo[i] mo i yu  -= mo[i] yu mo[i] mo i sum += Math.min(mo[i+1],yu) sum Math.min(mo[i+1],yu) Math.min Math mo[i+1] mo i+1 i 1 yu mo[i+1] = Math.max(0,mo[i+1]-yu) mo[i+1] mo i+1 i 1 Math.max(0,mo[i+1]-yu) Math.max Math 0 mo[i+1]-yu mo[i+1] mo i+1 i 1 yu {
          sum +=yu;
        } sum +=yu sum yu System.out.print(sum) System.out.print System.out System System.out sum String[] args args public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);		
		int N = in.nextInt();
        long mo[] = new long[N+1];
      
      for(int i = 0;i < N+1;i++){
      	mo[i] = in.nextInt(); 
      }
      
      long sum = 0;
      long yu = 0;
      
      for(int i =0;i < N;i++){
		yu = in.nextInt(); 
        
        if(yu>mo[i]){
        	sum += mo[i];
            yu  -= mo[i]; 
        	sum += Math.min(mo[i+1],yu);
            mo[i+1] = Math.max(0,mo[i+1]-yu); 
        }else{
          sum +=yu;
        }
      }
       System.out.print(sum); 
      }
	} public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);		
		int N = in.nextInt();
        long mo[] = new long[N+1];
      
      for(int i = 0;i < N+1;i++){
      	mo[i] = in.nextInt(); 
      }
      
      long sum = 0;
      long yu = 0;
      
      for(int i =0;i < N;i++){
		yu = in.nextInt(); 
        
        if(yu>mo[i]){
        	sum += mo[i];
            yu  -= mo[i]; 
        	sum += Math.min(mo[i+1],yu);
            mo[i+1] = Math.max(0,mo[i+1]-yu); 
        }else{
          sum +=yu;
        }
      }
       System.out.print(sum); 
      }
	} Main
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);		
		int N = in.nextInt();
        long mo[] = new long[N+1];
      
      for(int i = 0;i < N+1;i++){
      	mo[i] = in.nextInt(); 
      }
      
      long sum = 0;
      long yu = 0;
      
      for(int i =0;i < N;i++){
		yu = in.nextInt(); 
        
        if(yu>mo[i]){
        	sum += mo[i];
            yu  -= mo[i]; 
        	sum += Math.min(mo[i+1],yu);
            mo[i+1] = Math.max(0,mo[i+1]-yu); 
        }else{
          sum +=yu;
        }
      }
       System.out.print(sum); 
      }
	}