import java.util.*;
 
public class Main {
  public static void main (String[] arg) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    long A[] = new long[N+1];
    long B[] = new long[N];
    long Kc = 0;

    for (int i = 0; i < N+1; i++){
      A[i] = scan.nextLong();
    }

    for (int i = 0; i < N; i++){
      B[i] = scan.nextLong();
    }
    
    for(int i = 0; i < N; i++){
      if(B[i] > A[i]){
        B[i] -= A[i];
        Kc += A[i];
        if(B[i] > A[i+1]){
          Kc += A[i+1];
          A[i+1] = 0;
        } else {
          Kc += B[i];
          A[i+1] -= B[i];
        }
      } else {
        Kc += B[i];
      }
    }
    System.out.println(Kc);
  }
} import java.util.*; util.* java public class Main {
  public static void main (String[] arg) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    long A[] = new long[N+1];
    long B[] = new long[N];
    long Kc = 0;

    for (int i = 0; i < N+1; i++){
      A[i] = scan.nextLong();
    }

    for (int i = 0; i < N; i++){
      B[i] = scan.nextLong();
    }
    
    for(int i = 0; i < N; i++){
      if(B[i] > A[i]){
        B[i] -= A[i];
        Kc += A[i];
        if(B[i] > A[i+1]){
          Kc += A[i+1];
          A[i+1] = 0;
        } else {
          Kc += B[i];
          A[i+1] -= B[i];
        }
      } else {
        Kc += B[i];
      }
    }
    System.out.println(Kc);
  }
} Main public static void main (String[] arg) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    long A[] = new long[N+1];
    long B[] = new long[N];
    long Kc = 0;

    for (int i = 0; i < N+1; i++){
      A[i] = scan.nextLong();
    }

    for (int i = 0; i < N; i++){
      B[i] = scan.nextLong();
    }
    
    for(int i = 0; i < N; i++){
      if(B[i] > A[i]){
        B[i] -= A[i];
        Kc += A[i];
        if(B[i] > A[i+1]){
          Kc += A[i+1];
          A[i+1] = 0;
        } else {
          Kc += B[i];
          A[i+1] -= B[i];
        }
      } else {
        Kc += B[i];
      }
    }
    System.out.println(Kc);
  } main {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    long A[] = new long[N+1];
    long B[] = new long[N];
    long Kc = 0;

    for (int i = 0; i < N+1; i++){
      A[i] = scan.nextLong();
    }

    for (int i = 0; i < N; i++){
      B[i] = scan.nextLong();
    }
    
    for(int i = 0; i < N; i++){
      if(B[i] > A[i]){
        B[i] -= A[i];
        Kc += A[i];
        if(B[i] > A[i+1]){
          Kc += A[i+1];
          A[i+1] = 0;
        } else {
          Kc += B[i];
          A[i+1] -= B[i];
        }
      } else {
        Kc += B[i];
      }
    }
    System.out.println(Kc);
  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan 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 long Kc = 0; Kc 0 for (int i = 0; i < N+1; i++){
      A[i] = scan.nextLong();
    } int i = 0; int i = 0; i 0 i < N+1 i N+1 N 1 i++ i++ i {
      A[i] = scan.nextLong();
    } {
      A[i] = scan.nextLong();
    } A[i] = scan.nextLong() A[i] A i scan.nextLong() scan.nextLong scan for (int i = 0; i < N; i++){
      B[i] = scan.nextLong();
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      B[i] = scan.nextLong();
    } {
      B[i] = scan.nextLong();
    } B[i] = scan.nextLong() B[i] B i scan.nextLong() scan.nextLong scan for(int i = 0; i < N; i++){
      if(B[i] > A[i]){
        B[i] -= A[i];
        Kc += A[i];
        if(B[i] > A[i+1]){
          Kc += A[i+1];
          A[i+1] = 0;
        } else {
          Kc += B[i];
          A[i+1] -= B[i];
        }
      } else {
        Kc += B[i];
      }
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      if(B[i] > A[i]){
        B[i] -= A[i];
        Kc += A[i];
        if(B[i] > A[i+1]){
          Kc += A[i+1];
          A[i+1] = 0;
        } else {
          Kc += B[i];
          A[i+1] -= B[i];
        }
      } else {
        Kc += B[i];
      }
    } {
      if(B[i] > A[i]){
        B[i] -= A[i];
        Kc += A[i];
        if(B[i] > A[i+1]){
          Kc += A[i+1];
          A[i+1] = 0;
        } else {
          Kc += B[i];
          A[i+1] -= B[i];
        }
      } else {
        Kc += B[i];
      }
    } if(B[i] > A[i]){
        B[i] -= A[i];
        Kc += A[i];
        if(B[i] > A[i+1]){
          Kc += A[i+1];
          A[i+1] = 0;
        } else {
          Kc += B[i];
          A[i+1] -= B[i];
        }
      } else {
        Kc += B[i];
      } B[i] > A[i] B[i] B i A[i] A i {
        B[i] -= A[i];
        Kc += A[i];
        if(B[i] > A[i+1]){
          Kc += A[i+1];
          A[i+1] = 0;
        } else {
          Kc += B[i];
          A[i+1] -= B[i];
        }
      } B[i] -= A[i] B[i] B i A[i] A i Kc += A[i] Kc A[i] A i if(B[i] > A[i+1]){
          Kc += A[i+1];
          A[i+1] = 0;
        } else {
          Kc += B[i];
          A[i+1] -= B[i];
        } B[i] > A[i+1] B[i] B i A[i+1] A i+1 i 1 {
          Kc += A[i+1];
          A[i+1] = 0;
        } Kc += A[i+1] Kc A[i+1] A i+1 i 1 A[i+1] = 0 A[i+1] A i+1 i 1 0 {
          Kc += B[i];
          A[i+1] -= B[i];
        } Kc += B[i] Kc B[i] B i A[i+1] -= B[i] A[i+1] A i+1 i 1 B[i] B i {
        Kc += B[i];
      } Kc += B[i] Kc B[i] B i System.out.println(Kc) System.out.println System.out System System.out Kc String[] arg arg public class Main {
  public static void main (String[] arg) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    long A[] = new long[N+1];
    long B[] = new long[N];
    long Kc = 0;

    for (int i = 0; i < N+1; i++){
      A[i] = scan.nextLong();
    }

    for (int i = 0; i < N; i++){
      B[i] = scan.nextLong();
    }
    
    for(int i = 0; i < N; i++){
      if(B[i] > A[i]){
        B[i] -= A[i];
        Kc += A[i];
        if(B[i] > A[i+1]){
          Kc += A[i+1];
          A[i+1] = 0;
        } else {
          Kc += B[i];
          A[i+1] -= B[i];
        }
      } else {
        Kc += B[i];
      }
    }
    System.out.println(Kc);
  }
} public class Main {
  public static void main (String[] arg) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    long A[] = new long[N+1];
    long B[] = new long[N];
    long Kc = 0;

    for (int i = 0; i < N+1; i++){
      A[i] = scan.nextLong();
    }

    for (int i = 0; i < N; i++){
      B[i] = scan.nextLong();
    }
    
    for(int i = 0; i < N; i++){
      if(B[i] > A[i]){
        B[i] -= A[i];
        Kc += A[i];
        if(B[i] > A[i+1]){
          Kc += A[i+1];
          A[i+1] = 0;
        } else {
          Kc += B[i];
          A[i+1] -= B[i];
        }
      } else {
        Kc += B[i];
      }
    }
    System.out.println(Kc);
  }
} Main
import java.util.*;
 
public class Main {
  public static void main (String[] arg) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    long A[] = new long[N+1];
    long B[] = new long[N];
    long Kc = 0;

    for (int i = 0; i < N+1; i++){
      A[i] = scan.nextLong();
    }

    for (int i = 0; i < N; i++){
      B[i] = scan.nextLong();
    }
    
    for(int i = 0; i < N; i++){
      if(B[i] > A[i]){
        B[i] -= A[i];
        Kc += A[i];
        if(B[i] > A[i+1]){
          Kc += A[i+1];
          A[i+1] = 0;
        } else {
          Kc += B[i];
          A[i+1] -= B[i];
        }
      } else {
        Kc += B[i];
      }
    }
    System.out.println(Kc);
  }
}