//make sure to make new file!
import java.io.*;
import java.util.*;

public class Main{
   
   public static void main(String[] args)throws IOException{
      BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      PrintWriter out = new PrintWriter(System.out);
      
      int n = Integer.parseInt(f.readLine());
      
      StringTokenizer st = new StringTokenizer(f.readLine());
      long[] a = new long[n+1];
      for(int k = 0; k < n+1; k++){
         a[k] = Long.parseLong(st.nextToken());
      }
      
      st = new StringTokenizer(f.readLine());
      long[] b = new long[n];
      for(int k = 0; k < n; k++){
         b[k] = Long.parseLong(st.nextToken());
      }
      
      long answer = 0L;
      
      for(int k = 0; k < n; k++){
         answer += Math.min(a[k],b[k]);
         b[k] -= Math.min(a[k],b[k]);
         answer += Math.min(a[k+1],b[k]);
         a[k+1] -= Math.min(a[k+1],b[k]);
      }
      
      out.println(answer);
      
      
      
      out.close();
   }
   
      
} import java.io.*; io.* java import java.util.*; util.* java public class Main{
   
   public static void main(String[] args)throws IOException{
      BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      PrintWriter out = new PrintWriter(System.out);
      
      int n = Integer.parseInt(f.readLine());
      
      StringTokenizer st = new StringTokenizer(f.readLine());
      long[] a = new long[n+1];
      for(int k = 0; k < n+1; k++){
         a[k] = Long.parseLong(st.nextToken());
      }
      
      st = new StringTokenizer(f.readLine());
      long[] b = new long[n];
      for(int k = 0; k < n; k++){
         b[k] = Long.parseLong(st.nextToken());
      }
      
      long answer = 0L;
      
      for(int k = 0; k < n; k++){
         answer += Math.min(a[k],b[k]);
         b[k] -= Math.min(a[k],b[k]);
         answer += Math.min(a[k+1],b[k]);
         a[k+1] -= Math.min(a[k+1],b[k]);
      }
      
      out.println(answer);
      
      
      
      out.close();
   }
   
      
} Main public static void main(String[] args)throws IOException{
      BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      PrintWriter out = new PrintWriter(System.out);
      
      int n = Integer.parseInt(f.readLine());
      
      StringTokenizer st = new StringTokenizer(f.readLine());
      long[] a = new long[n+1];
      for(int k = 0; k < n+1; k++){
         a[k] = Long.parseLong(st.nextToken());
      }
      
      st = new StringTokenizer(f.readLine());
      long[] b = new long[n];
      for(int k = 0; k < n; k++){
         b[k] = Long.parseLong(st.nextToken());
      }
      
      long answer = 0L;
      
      for(int k = 0; k < n; k++){
         answer += Math.min(a[k],b[k]);
         b[k] -= Math.min(a[k],b[k]);
         answer += Math.min(a[k+1],b[k]);
         a[k+1] -= Math.min(a[k+1],b[k]);
      }
      
      out.println(answer);
      
      
      
      out.close();
   } main {
      BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      PrintWriter out = new PrintWriter(System.out);
      
      int n = Integer.parseInt(f.readLine());
      
      StringTokenizer st = new StringTokenizer(f.readLine());
      long[] a = new long[n+1];
      for(int k = 0; k < n+1; k++){
         a[k] = Long.parseLong(st.nextToken());
      }
      
      st = new StringTokenizer(f.readLine());
      long[] b = new long[n];
      for(int k = 0; k < n; k++){
         b[k] = Long.parseLong(st.nextToken());
      }
      
      long answer = 0L;
      
      for(int k = 0; k < n; k++){
         answer += Math.min(a[k],b[k]);
         b[k] -= Math.min(a[k],b[k]);
         answer += Math.min(a[k+1],b[k]);
         a[k+1] -= Math.min(a[k+1],b[k]);
      }
      
      out.println(answer);
      
      
      
      out.close();
   } BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); f new BufferedReader(new InputStreamReader(System.in)) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) int n = Integer.parseInt(f.readLine()); n Integer.parseInt(f.readLine()) Integer.parseInt Integer f.readLine() f.readLine f StringTokenizer st = new StringTokenizer(f.readLine()); st new StringTokenizer(f.readLine()) long[] a = new long[n+1]; a new long[n+1] n+1 n 1 for(int k = 0; k < n+1; k++){
         a[k] = Long.parseLong(st.nextToken());
      } int k = 0; int k = 0; k 0 k < n+1 k n+1 n 1 k++ k++ k {
         a[k] = Long.parseLong(st.nextToken());
      } {
         a[k] = Long.parseLong(st.nextToken());
      } a[k] = Long.parseLong(st.nextToken()) a[k] a k Long.parseLong(st.nextToken()) Long.parseLong Long st.nextToken() st.nextToken st st = new StringTokenizer(f.readLine()) st new StringTokenizer(f.readLine()) long[] b = new long[n]; b new long[n] n for(int k = 0; k < n; k++){
         b[k] = Long.parseLong(st.nextToken());
      } int k = 0; int k = 0; k 0 k < n k n k++ k++ k {
         b[k] = Long.parseLong(st.nextToken());
      } {
         b[k] = Long.parseLong(st.nextToken());
      } b[k] = Long.parseLong(st.nextToken()) b[k] b k Long.parseLong(st.nextToken()) Long.parseLong Long st.nextToken() st.nextToken st long answer = 0L; answer 0L for(int k = 0; k < n; k++){
         answer += Math.min(a[k],b[k]);
         b[k] -= Math.min(a[k],b[k]);
         answer += Math.min(a[k+1],b[k]);
         a[k+1] -= Math.min(a[k+1],b[k]);
      } int k = 0; int k = 0; k 0 k < n k n k++ k++ k {
         answer += Math.min(a[k],b[k]);
         b[k] -= Math.min(a[k],b[k]);
         answer += Math.min(a[k+1],b[k]);
         a[k+1] -= Math.min(a[k+1],b[k]);
      } {
         answer += Math.min(a[k],b[k]);
         b[k] -= Math.min(a[k],b[k]);
         answer += Math.min(a[k+1],b[k]);
         a[k+1] -= Math.min(a[k+1],b[k]);
      } answer += Math.min(a[k],b[k]) answer Math.min(a[k],b[k]) Math.min Math a[k] a k b[k] b k b[k] -= Math.min(a[k],b[k]) b[k] b k Math.min(a[k],b[k]) Math.min Math a[k] a k b[k] b k answer += Math.min(a[k+1],b[k]) answer Math.min(a[k+1],b[k]) Math.min Math a[k+1] a k+1 k 1 b[k] b k a[k+1] -= Math.min(a[k+1],b[k]) a[k+1] a k+1 k 1 Math.min(a[k+1],b[k]) Math.min Math a[k+1] a k+1 k 1 b[k] b k out.println(answer) out.println out answer out.close() out.close out String[] args args public class Main{
   
   public static void main(String[] args)throws IOException{
      BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      PrintWriter out = new PrintWriter(System.out);
      
      int n = Integer.parseInt(f.readLine());
      
      StringTokenizer st = new StringTokenizer(f.readLine());
      long[] a = new long[n+1];
      for(int k = 0; k < n+1; k++){
         a[k] = Long.parseLong(st.nextToken());
      }
      
      st = new StringTokenizer(f.readLine());
      long[] b = new long[n];
      for(int k = 0; k < n; k++){
         b[k] = Long.parseLong(st.nextToken());
      }
      
      long answer = 0L;
      
      for(int k = 0; k < n; k++){
         answer += Math.min(a[k],b[k]);
         b[k] -= Math.min(a[k],b[k]);
         answer += Math.min(a[k+1],b[k]);
         a[k+1] -= Math.min(a[k+1],b[k]);
      }
      
      out.println(answer);
      
      
      
      out.close();
   }
   
      
} public class Main{
   
   public static void main(String[] args)throws IOException{
      BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      PrintWriter out = new PrintWriter(System.out);
      
      int n = Integer.parseInt(f.readLine());
      
      StringTokenizer st = new StringTokenizer(f.readLine());
      long[] a = new long[n+1];
      for(int k = 0; k < n+1; k++){
         a[k] = Long.parseLong(st.nextToken());
      }
      
      st = new StringTokenizer(f.readLine());
      long[] b = new long[n];
      for(int k = 0; k < n; k++){
         b[k] = Long.parseLong(st.nextToken());
      }
      
      long answer = 0L;
      
      for(int k = 0; k < n; k++){
         answer += Math.min(a[k],b[k]);
         b[k] -= Math.min(a[k],b[k]);
         answer += Math.min(a[k+1],b[k]);
         a[k+1] -= Math.min(a[k+1],b[k]);
      }
      
      out.println(answer);
      
      
      
      out.close();
   }
   
      
} Main
//make sure to make new file!
import java.io.*;
import java.util.*;

public class Main{
   
   public static void main(String[] args)throws IOException{
      BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      PrintWriter out = new PrintWriter(System.out);
      
      int n = Integer.parseInt(f.readLine());
      
      StringTokenizer st = new StringTokenizer(f.readLine());
      long[] a = new long[n+1];
      for(int k = 0; k < n+1; k++){
         a[k] = Long.parseLong(st.nextToken());
      }
      
      st = new StringTokenizer(f.readLine());
      long[] b = new long[n];
      for(int k = 0; k < n; k++){
         b[k] = Long.parseLong(st.nextToken());
      }
      
      long answer = 0L;
      
      for(int k = 0; k < n; k++){
         answer += Math.min(a[k],b[k]);
         b[k] -= Math.min(a[k],b[k]);
         answer += Math.min(a[k+1],b[k]);
         a[k+1] -= Math.min(a[k+1],b[k]);
      }
      
      out.println(answer);
      
      
      
      out.close();
   }
   
      
}