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