import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next()); 
    long[] A = new long[N+1];  
    long[] B = new long[N];  
    for (int i=0; i < N+1 ;i++) {
      A[i] = Integer.parseInt(sc.next()); 
    }
    for (int i=0; i < N ;i++) {
      B[i] = Integer.parseInt(sc.next()); 
      }
    long count = 0;
    for(int i=0;i<N;i++ ){
      if(B[i]>=A[i]){
        count += A[i];
        long tmp = B[i] - A[i];
        A[i] = 0;
        if(tmp>=A[i+1]){
          count += A[i+1];
          A[i+1] = 0;
        }else{
          count += tmp;
          A[i+1] -= tmp;
        }
      }else{
        A[i] -= B[i]; 
        count += B[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 = Integer.parseInt(sc.next()); 
    long[] A = new long[N+1];  
    long[] B = new long[N];  
    for (int i=0; i < N+1 ;i++) {
      A[i] = Integer.parseInt(sc.next()); 
    }
    for (int i=0; i < N ;i++) {
      B[i] = Integer.parseInt(sc.next()); 
      }
    long count = 0;
    for(int i=0;i<N;i++ ){
      if(B[i]>=A[i]){
        count += A[i];
        long tmp = B[i] - A[i];
        A[i] = 0;
        if(tmp>=A[i+1]){
          count += A[i+1];
          A[i+1] = 0;
        }else{
          count += tmp;
          A[i+1] -= tmp;
        }
      }else{
        A[i] -= B[i]; 
        count += B[i];

      }
    }
    System.out.println(count);
  }
  
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next()); 
    long[] A = new long[N+1];  
    long[] B = new long[N];  
    for (int i=0; i < N+1 ;i++) {
      A[i] = Integer.parseInt(sc.next()); 
    }
    for (int i=0; i < N ;i++) {
      B[i] = Integer.parseInt(sc.next()); 
      }
    long count = 0;
    for(int i=0;i<N;i++ ){
      if(B[i]>=A[i]){
        count += A[i];
        long tmp = B[i] - A[i];
        A[i] = 0;
        if(tmp>=A[i+1]){
          count += A[i+1];
          A[i+1] = 0;
        }else{
          count += tmp;
          A[i+1] -= tmp;
        }
      }else{
        A[i] -= B[i]; 
        count += B[i];

      }
    }
    System.out.println(count);
  } main {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next()); 
    long[] A = new long[N+1];  
    long[] B = new long[N];  
    for (int i=0; i < N+1 ;i++) {
      A[i] = Integer.parseInt(sc.next()); 
    }
    for (int i=0; i < N ;i++) {
      B[i] = Integer.parseInt(sc.next()); 
      }
    long count = 0;
    for(int i=0;i<N;i++ ){
      if(B[i]>=A[i]){
        count += A[i];
        long tmp = B[i] - A[i];
        A[i] = 0;
        if(tmp>=A[i+1]){
          count += A[i+1];
          A[i+1] = 0;
        }else{
          count += tmp;
          A[i+1] -= tmp;
        }
      }else{
        A[i] -= B[i]; 
        count += B[i];

      }
    }
    System.out.println(count);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next 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+1 ;i++) {
      A[i] = Integer.parseInt(sc.next()); 
    } int i=0; int i=0; i 0 i < N+1 i N+1 N 1 i++ i++ i {
      A[i] = Integer.parseInt(sc.next()); 
    } {
      A[i] = Integer.parseInt(sc.next()); 
    } A[i] = Integer.parseInt(sc.next()) A[i] A i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc for (int i=0; i < N ;i++) {
      B[i] = Integer.parseInt(sc.next()); 
      } int i=0; int i=0; i 0 i < N i N i++ i++ i {
      B[i] = Integer.parseInt(sc.next()); 
      } {
      B[i] = Integer.parseInt(sc.next()); 
      } B[i] = Integer.parseInt(sc.next()) B[i] B i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc long count = 0; count 0 for(int i=0;i<N;i++ ){
      if(B[i]>=A[i]){
        count += A[i];
        long tmp = B[i] - A[i];
        A[i] = 0;
        if(tmp>=A[i+1]){
          count += A[i+1];
          A[i+1] = 0;
        }else{
          count += tmp;
          A[i+1] -= tmp;
        }
      }else{
        A[i] -= B[i]; 
        count += B[i];

      }
    } int i=0; int i=0; i 0 i<N i N i++ i++ i {
      if(B[i]>=A[i]){
        count += A[i];
        long tmp = B[i] - A[i];
        A[i] = 0;
        if(tmp>=A[i+1]){
          count += A[i+1];
          A[i+1] = 0;
        }else{
          count += tmp;
          A[i+1] -= tmp;
        }
      }else{
        A[i] -= B[i]; 
        count += B[i];

      }
    } {
      if(B[i]>=A[i]){
        count += A[i];
        long tmp = B[i] - A[i];
        A[i] = 0;
        if(tmp>=A[i+1]){
          count += A[i+1];
          A[i+1] = 0;
        }else{
          count += tmp;
          A[i+1] -= tmp;
        }
      }else{
        A[i] -= B[i]; 
        count += B[i];

      }
    } if(B[i]>=A[i]){
        count += A[i];
        long tmp = B[i] - A[i];
        A[i] = 0;
        if(tmp>=A[i+1]){
          count += A[i+1];
          A[i+1] = 0;
        }else{
          count += tmp;
          A[i+1] -= tmp;
        }
      }else{
        A[i] -= B[i]; 
        count += B[i];

      } B[i]>=A[i] B[i] B i A[i] A i {
        count += A[i];
        long tmp = B[i] - A[i];
        A[i] = 0;
        if(tmp>=A[i+1]){
          count += A[i+1];
          A[i+1] = 0;
        }else{
          count += tmp;
          A[i+1] -= tmp;
        }
      } count += A[i] count A[i] A i long tmp = B[i] - A[i]; tmp B[i] - A[i] B[i] B i A[i] A i A[i] = 0 A[i] A i 0 if(tmp>=A[i+1]){
          count += A[i+1];
          A[i+1] = 0;
        }else{
          count += tmp;
          A[i+1] -= tmp;
        } tmp>=A[i+1] tmp A[i+1] A i+1 i 1 {
          count += A[i+1];
          A[i+1] = 0;
        } count += A[i+1] count A[i+1] A i+1 i 1 A[i+1] = 0 A[i+1] A i+1 i 1 0 {
          count += tmp;
          A[i+1] -= tmp;
        } count += tmp count tmp A[i+1] -= tmp A[i+1] A i+1 i 1 tmp {
        A[i] -= B[i]; 
        count += B[i];

      } A[i] -= B[i] A[i] A i B[i] B i count += B[i] count B[i] B 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 = Integer.parseInt(sc.next()); 
    long[] A = new long[N+1];  
    long[] B = new long[N];  
    for (int i=0; i < N+1 ;i++) {
      A[i] = Integer.parseInt(sc.next()); 
    }
    for (int i=0; i < N ;i++) {
      B[i] = Integer.parseInt(sc.next()); 
      }
    long count = 0;
    for(int i=0;i<N;i++ ){
      if(B[i]>=A[i]){
        count += A[i];
        long tmp = B[i] - A[i];
        A[i] = 0;
        if(tmp>=A[i+1]){
          count += A[i+1];
          A[i+1] = 0;
        }else{
          count += tmp;
          A[i+1] -= tmp;
        }
      }else{
        A[i] -= B[i]; 
        count += B[i];

      }
    }
    System.out.println(count);
  }
  
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next()); 
    long[] A = new long[N+1];  
    long[] B = new long[N];  
    for (int i=0; i < N+1 ;i++) {
      A[i] = Integer.parseInt(sc.next()); 
    }
    for (int i=0; i < N ;i++) {
      B[i] = Integer.parseInt(sc.next()); 
      }
    long count = 0;
    for(int i=0;i<N;i++ ){
      if(B[i]>=A[i]){
        count += A[i];
        long tmp = B[i] - A[i];
        A[i] = 0;
        if(tmp>=A[i+1]){
          count += A[i+1];
          A[i+1] = 0;
        }else{
          count += tmp;
          A[i+1] -= tmp;
        }
      }else{
        A[i] -= B[i]; 
        count += B[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 = Integer.parseInt(sc.next()); 
    long[] A = new long[N+1];  
    long[] B = new long[N];  
    for (int i=0; i < N+1 ;i++) {
      A[i] = Integer.parseInt(sc.next()); 
    }
    for (int i=0; i < N ;i++) {
      B[i] = Integer.parseInt(sc.next()); 
      }
    long count = 0;
    for(int i=0;i<N;i++ ){
      if(B[i]>=A[i]){
        count += A[i];
        long tmp = B[i] - A[i];
        A[i] = 0;
        if(tmp>=A[i+1]){
          count += A[i+1];
          A[i+1] = 0;
        }else{
          count += tmp;
          A[i+1] -= tmp;
        }
      }else{
        A[i] -= B[i]; 
        count += B[i];

      }
    }
    System.out.println(count);
  }
  
}

