import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    
    long[] A = new long[N+1];
    for(int i = 0; i < N+1; i++){
      A[i] = scanner.nextLong();
    }
    
    long[] B = new long[N];
    for(int i = 0; i < N; i++){
      B[i] = scanner.nextLong();
    }
    
    /*
    * 勇者はn,n+1の順に倒していくと多く倒せる
    * 次の勇者はn番目を倒すことができないから
    */
    
    long total = 0;
    
    for(int n = 0; n < N; n++){
      long amount = Math.min(A[n], B[n]);
      B[n] -= amount;
      total += amount;
      
      amount = Math.min(A[n+1], B[n]);
      A[n+1] -= amount;
      total += amount;
    }
 
    System.out.println(total);
  }
} import java.util.*; util.* java public class Main{
  public static void main(String args[]){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    
    long[] A = new long[N+1];
    for(int i = 0; i < N+1; i++){
      A[i] = scanner.nextLong();
    }
    
    long[] B = new long[N];
    for(int i = 0; i < N; i++){
      B[i] = scanner.nextLong();
    }
    
    /*
    * 勇者はn,n+1の順に倒していくと多く倒せる
    * 次の勇者はn番目を倒すことができないから
    */
    
    long total = 0;
    
    for(int n = 0; n < N; n++){
      long amount = Math.min(A[n], B[n]);
      B[n] -= amount;
      total += amount;
      
      amount = Math.min(A[n+1], B[n]);
      A[n+1] -= amount;
      total += amount;
    }
 
    System.out.println(total);
  }
} Main public static void main(String args[]){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    
    long[] A = new long[N+1];
    for(int i = 0; i < N+1; i++){
      A[i] = scanner.nextLong();
    }
    
    long[] B = new long[N];
    for(int i = 0; i < N; i++){
      B[i] = scanner.nextLong();
    }
    
    /*
    * 勇者はn,n+1の順に倒していくと多く倒せる
    * 次の勇者はn番目を倒すことができないから
    */
    
    long total = 0;
    
    for(int n = 0; n < N; n++){
      long amount = Math.min(A[n], B[n]);
      B[n] -= amount;
      total += amount;
      
      amount = Math.min(A[n+1], B[n]);
      A[n+1] -= amount;
      total += amount;
    }
 
    System.out.println(total);
  } main {
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    
    long[] A = new long[N+1];
    for(int i = 0; i < N+1; i++){
      A[i] = scanner.nextLong();
    }
    
    long[] B = new long[N];
    for(int i = 0; i < N; i++){
      B[i] = scanner.nextLong();
    }
    
    /*
    * 勇者はn,n+1の順に倒していくと多く倒せる
    * 次の勇者はn番目を倒すことができないから
    */
    
    long total = 0;
    
    for(int n = 0; n < N; n++){
      long amount = Math.min(A[n], B[n]);
      B[n] -= amount;
      total += amount;
      
      amount = Math.min(A[n+1], B[n]);
      A[n+1] -= amount;
      total += amount;
    }
 
    System.out.println(total);
  } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner long[] A = new long[N+1]; A new long[N+1] N+1 N 1 for(int i = 0; i < N+1; i++){
      A[i] = scanner.nextLong();
    } int i = 0; int i = 0; i 0 i < N+1 i N+1 N 1 i++ i++ i {
      A[i] = scanner.nextLong();
    } {
      A[i] = scanner.nextLong();
    } A[i] = scanner.nextLong() A[i] A i scanner.nextLong() scanner.nextLong scanner long[] B = new long[N]; B new long[N] N for(int i = 0; i < N; i++){
      B[i] = scanner.nextLong();
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      B[i] = scanner.nextLong();
    } {
      B[i] = scanner.nextLong();
    } B[i] = scanner.nextLong() B[i] B i scanner.nextLong() scanner.nextLong scanner long total = 0; total 0 for(int n = 0; n < N; n++){
      long amount = Math.min(A[n], B[n]);
      B[n] -= amount;
      total += amount;
      
      amount = Math.min(A[n+1], B[n]);
      A[n+1] -= amount;
      total += amount;
    } int n = 0; int n = 0; n 0 n < N n N n++ n++ n {
      long amount = Math.min(A[n], B[n]);
      B[n] -= amount;
      total += amount;
      
      amount = Math.min(A[n+1], B[n]);
      A[n+1] -= amount;
      total += amount;
    } {
      long amount = Math.min(A[n], B[n]);
      B[n] -= amount;
      total += amount;
      
      amount = Math.min(A[n+1], B[n]);
      A[n+1] -= amount;
      total += amount;
    } long amount = Math.min(A[n], B[n]); amount Math.min(A[n], B[n]) Math.min Math A[n] A n B[n] B n B[n] -= amount B[n] B n amount total += amount total amount amount = Math.min(A[n+1], B[n]) amount Math.min(A[n+1], B[n]) Math.min Math A[n+1] A n+1 n 1 B[n] B n A[n+1] -= amount A[n+1] A n+1 n 1 amount total += amount total amount System.out.println(total) System.out.println System.out System System.out total String args[] args public class Main{
  public static void main(String args[]){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    
    long[] A = new long[N+1];
    for(int i = 0; i < N+1; i++){
      A[i] = scanner.nextLong();
    }
    
    long[] B = new long[N];
    for(int i = 0; i < N; i++){
      B[i] = scanner.nextLong();
    }
    
    /*
    * 勇者はn,n+1の順に倒していくと多く倒せる
    * 次の勇者はn番目を倒すことができないから
    */
    
    long total = 0;
    
    for(int n = 0; n < N; n++){
      long amount = Math.min(A[n], B[n]);
      B[n] -= amount;
      total += amount;
      
      amount = Math.min(A[n+1], B[n]);
      A[n+1] -= amount;
      total += amount;
    }
 
    System.out.println(total);
  }
} public class Main{
  public static void main(String args[]){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    
    long[] A = new long[N+1];
    for(int i = 0; i < N+1; i++){
      A[i] = scanner.nextLong();
    }
    
    long[] B = new long[N];
    for(int i = 0; i < N; i++){
      B[i] = scanner.nextLong();
    }
    
    /*
    * 勇者はn,n+1の順に倒していくと多く倒せる
    * 次の勇者はn番目を倒すことができないから
    */
    
    long total = 0;
    
    for(int n = 0; n < N; n++){
      long amount = Math.min(A[n], B[n]);
      B[n] -= amount;
      total += amount;
      
      amount = Math.min(A[n+1], B[n]);
      A[n+1] -= amount;
      total += amount;
    }
 
    System.out.println(total);
  }
} Main
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    
    long[] A = new long[N+1];
    for(int i = 0; i < N+1; i++){
      A[i] = scanner.nextLong();
    }
    
    long[] B = new long[N];
    for(int i = 0; i < N; i++){
      B[i] = scanner.nextLong();
    }
    
    /*
    * 勇者はn,n+1の順に倒していくと多く倒せる
    * 次の勇者はn番目を倒すことができないから
    */
    
    long total = 0;
    
    for(int n = 0; n < N; n++){
      long amount = Math.min(A[n], B[n]);
      B[n] -= amount;
      total += amount;
      
      amount = Math.min(A[n+1], B[n]);
      A[n+1] -= amount;
      total += amount;
    }
 
    System.out.println(total);
  }
}