import java.util.*;
import static java.lang.System.*;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  
	  int N = sc.nextInt();
	  int[] A = new int[N+1];
	  int[] B = new int[N];
	  long count = 0;  
	  for(int i=0; i<N+1; i++) {
		  A[i] = sc.nextInt();
	  }
	  for(int i=0; i<N; i++) {
		  B[i] = sc.nextInt();
	  }
	  
	  for(int i=0; i<N; i++) {
		  int n = Math.min(A[i], B[i]);
		  count += n;
		  B[i] -= n;
		  A[i] -= n;
		  int m = Math.min(A[i+1], B[i]);
		  count += m;
		  A[i+1] -= m;
	  }
	  out.println(count);  
	  
  }
} import java.util.*; util.* java import static java.lang.System.*; import static java.lang.System.*; import static java.lang.System.*; public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  
	  int N = sc.nextInt();
	  int[] A = new int[N+1];
	  int[] B = new int[N];
	  long count = 0;  
	  for(int i=0; i<N+1; i++) {
		  A[i] = sc.nextInt();
	  }
	  for(int i=0; i<N; i++) {
		  B[i] = sc.nextInt();
	  }
	  
	  for(int i=0; i<N; i++) {
		  int n = Math.min(A[i], B[i]);
		  count += n;
		  B[i] -= n;
		  A[i] -= n;
		  int m = Math.min(A[i+1], B[i]);
		  count += m;
		  A[i+1] -= m;
	  }
	  out.println(count);  
	  
  }
} Main public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  
	  int N = sc.nextInt();
	  int[] A = new int[N+1];
	  int[] B = new int[N];
	  long count = 0;  
	  for(int i=0; i<N+1; i++) {
		  A[i] = sc.nextInt();
	  }
	  for(int i=0; i<N; i++) {
		  B[i] = sc.nextInt();
	  }
	  
	  for(int i=0; i<N; i++) {
		  int n = Math.min(A[i], B[i]);
		  count += n;
		  B[i] -= n;
		  A[i] -= n;
		  int m = Math.min(A[i+1], B[i]);
		  count += m;
		  A[i+1] -= m;
	  }
	  out.println(count);  
	  
  } main {
	  Scanner sc = new Scanner(System.in);
	  
	  int N = sc.nextInt();
	  int[] A = new int[N+1];
	  int[] B = new int[N];
	  long count = 0;  
	  for(int i=0; i<N+1; i++) {
		  A[i] = sc.nextInt();
	  }
	  for(int i=0; i<N; i++) {
		  B[i] = sc.nextInt();
	  }
	  
	  for(int i=0; i<N; i++) {
		  int n = Math.min(A[i], B[i]);
		  count += n;
		  B[i] -= n;
		  A[i] -= n;
		  int m = Math.min(A[i+1], B[i]);
		  count += m;
		  A[i+1] -= m;
	  }
	  out.println(count);  
	  
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] A = new int[N+1]; A new int[N+1] N+1 N 1 int[] B = new int[N]; B new int[N] N long count = 0; count 0 for(int i=0; i<N+1; i++) {
		  A[i] = sc.nextInt();
	  } int i=0; int i=0; i 0 i<N+1 i N+1 N 1 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 for(int i=0; i<N; i++) {
		  int n = Math.min(A[i], B[i]);
		  count += n;
		  B[i] -= n;
		  A[i] -= n;
		  int m = Math.min(A[i+1], B[i]);
		  count += m;
		  A[i+1] -= m;
	  } int i=0; int i=0; i 0 i<N i N i++ i++ i {
		  int n = Math.min(A[i], B[i]);
		  count += n;
		  B[i] -= n;
		  A[i] -= n;
		  int m = Math.min(A[i+1], B[i]);
		  count += m;
		  A[i+1] -= m;
	  } {
		  int n = Math.min(A[i], B[i]);
		  count += n;
		  B[i] -= n;
		  A[i] -= n;
		  int m = Math.min(A[i+1], B[i]);
		  count += m;
		  A[i+1] -= m;
	  } int n = Math.min(A[i], B[i]); n Math.min(A[i], B[i]) Math.min Math A[i] A i B[i] B i count += n count n B[i] -= n B[i] B i n A[i] -= n A[i] A i n int m = Math.min(A[i+1], B[i]); m Math.min(A[i+1], B[i]) Math.min Math A[i+1] A i+1 i 1 B[i] B i count += m count m A[i+1] -= m A[i+1] A i+1 i 1 m out.println(count) out.println out count String[] args args public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  
	  int N = sc.nextInt();
	  int[] A = new int[N+1];
	  int[] B = new int[N];
	  long count = 0;  
	  for(int i=0; i<N+1; i++) {
		  A[i] = sc.nextInt();
	  }
	  for(int i=0; i<N; i++) {
		  B[i] = sc.nextInt();
	  }
	  
	  for(int i=0; i<N; i++) {
		  int n = Math.min(A[i], B[i]);
		  count += n;
		  B[i] -= n;
		  A[i] -= n;
		  int m = Math.min(A[i+1], B[i]);
		  count += m;
		  A[i+1] -= m;
	  }
	  out.println(count);  
	  
  }
} public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  
	  int N = sc.nextInt();
	  int[] A = new int[N+1];
	  int[] B = new int[N];
	  long count = 0;  
	  for(int i=0; i<N+1; i++) {
		  A[i] = sc.nextInt();
	  }
	  for(int i=0; i<N; i++) {
		  B[i] = sc.nextInt();
	  }
	  
	  for(int i=0; i<N; i++) {
		  int n = Math.min(A[i], B[i]);
		  count += n;
		  B[i] -= n;
		  A[i] -= n;
		  int m = Math.min(A[i+1], B[i]);
		  count += m;
		  A[i+1] -= m;
	  }
	  out.println(count);  
	  
  }
} Main
import java.util.*;
import static java.lang.System.*;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  
	  int N = sc.nextInt();
	  int[] A = new int[N+1];
	  int[] B = new int[N];
	  long count = 0;  
	  for(int i=0; i<N+1; i++) {
		  A[i] = sc.nextInt();
	  }
	  for(int i=0; i<N; i++) {
		  B[i] = sc.nextInt();
	  }
	  
	  for(int i=0; i<N; i++) {
		  int n = Math.min(A[i], B[i]);
		  count += n;
		  B[i] -= n;
		  A[i] -= n;
		  int m = Math.min(A[i+1], B[i]);
		  count += m;
		  A[i+1] -= m;
	  }
	  out.println(count);  
	  
  }
}