import java.util.*;
public class Main {

  public static void main (String[] args) {
	
    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    
    long[] A = new long[N+1];
    long[] B = new long[N];
    
    for (int i = 0; i <= N; i++) {
      A[i] = sc.nextInt();
    }

    for (int i = 0; i < N; i++) {
      B[i] = sc.nextInt();
    }

    sc.close();

    long count = 0;

    long A_ = A[N];

    for (int i = N-1; 0 <= i; i--){

      A_ = A[i] + A_;

      if (A_ <= B[i]) {

        count = count + A_;
      
        A_ = 0;
     
      } else {
      
        count = count + B[i];
      
        if ((A_ - B[i]) < A[i]){
      
          A_ = A_ - B[i];
      
        } else {
      
          A_ = A[i];
      
        }

      }
    }

    System.out.println(count);
 
  }

} import java.util.*; util.* java public class Main {

  public static void main (String[] args) {
	
    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    
    long[] A = new long[N+1];
    long[] B = new long[N];
    
    for (int i = 0; i <= N; i++) {
      A[i] = sc.nextInt();
    }

    for (int i = 0; i < N; i++) {
      B[i] = sc.nextInt();
    }

    sc.close();

    long count = 0;

    long A_ = A[N];

    for (int i = N-1; 0 <= i; i--){

      A_ = A[i] + A_;

      if (A_ <= B[i]) {

        count = count + A_;
      
        A_ = 0;
     
      } else {
      
        count = count + B[i];
      
        if ((A_ - B[i]) < A[i]){
      
          A_ = A_ - B[i];
      
        } else {
      
          A_ = A[i];
      
        }

      }
    }

    System.out.println(count);
 
  }

} Main public static void main (String[] args) {
	
    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    
    long[] A = new long[N+1];
    long[] B = new long[N];
    
    for (int i = 0; i <= N; i++) {
      A[i] = sc.nextInt();
    }

    for (int i = 0; i < N; i++) {
      B[i] = sc.nextInt();
    }

    sc.close();

    long count = 0;

    long A_ = A[N];

    for (int i = N-1; 0 <= i; i--){

      A_ = A[i] + A_;

      if (A_ <= B[i]) {

        count = count + A_;
      
        A_ = 0;
     
      } else {
      
        count = count + B[i];
      
        if ((A_ - B[i]) < A[i]){
      
          A_ = A_ - B[i];
      
        } else {
      
          A_ = A[i];
      
        }

      }
    }

    System.out.println(count);
 
  } main {
	
    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    
    long[] A = new long[N+1];
    long[] B = new long[N];
    
    for (int i = 0; i <= N; i++) {
      A[i] = sc.nextInt();
    }

    for (int i = 0; i < N; i++) {
      B[i] = sc.nextInt();
    }

    sc.close();

    long count = 0;

    long A_ = A[N];

    for (int i = N-1; 0 <= i; i--){

      A_ = A[i] + A_;

      if (A_ <= B[i]) {

        count = count + A_;
      
        A_ = 0;
     
      } else {
      
        count = count + B[i];
      
        if ((A_ - B[i]) < A[i]){
      
          A_ = A_ - B[i];
      
        } else {
      
          A_ = A[i];
      
        }

      }
    }

    System.out.println(count);
 
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc long[] A = new long[N+1]; A new long[N+1] N+1 N 1 long[] B = new long[N]; B new long[N] N for (int i = 0; i <= N; i++) {
      A[i] = sc.nextInt();
    } int i = 0; int i = 0; i 0 i <= N i N 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 sc.close() sc.close sc long count = 0; count 0 long A_ = A[N]; A_ A[N] A N for (int i = N-1; 0 <= i; i--){

      A_ = A[i] + A_;

      if (A_ <= B[i]) {

        count = count + A_;
      
        A_ = 0;
     
      } else {
      
        count = count + B[i];
      
        if ((A_ - B[i]) < A[i]){
      
          A_ = A_ - B[i];
      
        } else {
      
          A_ = A[i];
      
        }

      }
    } int i = N-1; int i = N-1; i N-1 N 1 0 <= i 0 i i-- i-- i {

      A_ = A[i] + A_;

      if (A_ <= B[i]) {

        count = count + A_;
      
        A_ = 0;
     
      } else {
      
        count = count + B[i];
      
        if ((A_ - B[i]) < A[i]){
      
          A_ = A_ - B[i];
      
        } else {
      
          A_ = A[i];
      
        }

      }
    } {

      A_ = A[i] + A_;

      if (A_ <= B[i]) {

        count = count + A_;
      
        A_ = 0;
     
      } else {
      
        count = count + B[i];
      
        if ((A_ - B[i]) < A[i]){
      
          A_ = A_ - B[i];
      
        } else {
      
          A_ = A[i];
      
        }

      }
    } A_ = A[i] + A_ A_ A[i] + A_ A[i] A i A_ if (A_ <= B[i]) {

        count = count + A_;
      
        A_ = 0;
     
      } else {
      
        count = count + B[i];
      
        if ((A_ - B[i]) < A[i]){
      
          A_ = A_ - B[i];
      
        } else {
      
          A_ = A[i];
      
        }

      } A_ <= B[i] A_ B[i] B i {

        count = count + A_;
      
        A_ = 0;
     
      } count = count + A_ count count + A_ count A_ A_ = 0 A_ 0 {
      
        count = count + B[i];
      
        if ((A_ - B[i]) < A[i]){
      
          A_ = A_ - B[i];
      
        } else {
      
          A_ = A[i];
      
        }

      } count = count + B[i] count count + B[i] count B[i] B i if ((A_ - B[i]) < A[i]){
      
          A_ = A_ - B[i];
      
        } else {
      
          A_ = A[i];
      
        } (A_ - B[i]) < A[i] (A_ - B[i]) A_ B[i] B i A[i] A i {
      
          A_ = A_ - B[i];
      
        } A_ = A_ - B[i] A_ A_ - B[i] A_ B[i] B i {
      
          A_ = A[i];
      
        } A_ = A[i] A_ A[i] A i System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {

  public static void main (String[] args) {
	
    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    
    long[] A = new long[N+1];
    long[] B = new long[N];
    
    for (int i = 0; i <= N; i++) {
      A[i] = sc.nextInt();
    }

    for (int i = 0; i < N; i++) {
      B[i] = sc.nextInt();
    }

    sc.close();

    long count = 0;

    long A_ = A[N];

    for (int i = N-1; 0 <= i; i--){

      A_ = A[i] + A_;

      if (A_ <= B[i]) {

        count = count + A_;
      
        A_ = 0;
     
      } else {
      
        count = count + B[i];
      
        if ((A_ - B[i]) < A[i]){
      
          A_ = A_ - B[i];
      
        } else {
      
          A_ = A[i];
      
        }

      }
    }

    System.out.println(count);
 
  }

} public class Main {

  public static void main (String[] args) {
	
    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    
    long[] A = new long[N+1];
    long[] B = new long[N];
    
    for (int i = 0; i <= N; i++) {
      A[i] = sc.nextInt();
    }

    for (int i = 0; i < N; i++) {
      B[i] = sc.nextInt();
    }

    sc.close();

    long count = 0;

    long A_ = A[N];

    for (int i = N-1; 0 <= i; i--){

      A_ = A[i] + A_;

      if (A_ <= B[i]) {

        count = count + A_;
      
        A_ = 0;
     
      } else {
      
        count = count + B[i];
      
        if ((A_ - B[i]) < A[i]){
      
          A_ = A_ - B[i];
      
        } else {
      
          A_ = A[i];
      
        }

      }
    }

    System.out.println(count);
 
  }

} Main
import java.util.*;
public class Main {

  public static void main (String[] args) {
	
    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    
    long[] A = new long[N+1];
    long[] B = new long[N];
    
    for (int i = 0; i <= N; i++) {
      A[i] = sc.nextInt();
    }

    for (int i = 0; i < N; i++) {
      B[i] = sc.nextInt();
    }

    sc.close();

    long count = 0;

    long A_ = A[N];

    for (int i = N-1; 0 <= i; i--){

      A_ = A[i] + A_;

      if (A_ <= B[i]) {

        count = count + A_;
      
        A_ = 0;
     
      } else {
      
        count = count + B[i];
      
        if ((A_ - B[i]) < A[i]){
      
          A_ = A_ - B[i];
      
        } else {
      
          A_ = A[i];
      
        }

      }
    }

    System.out.println(count);
 
  }

}