/*
Roses are red
Memes are neat
All my test cases time out
Lmao yeet
*/
import java.util.*;
import java.io.*;

   public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N+1];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i <= N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         int[] brr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            brr[i] = Integer.parseInt(st.nextToken());
         long res = 0L;
         for(int i=0; i < N; i++)
         {
            int pow = brr[i];
            if(pow <= arr[i])
            {
               res += pow;
               arr[i] -= pow;
               brr[i] = 0;
            }
            else
            {
               res += arr[i];
               pow -= arr[i];
               arr[i] = 0;
               if(arr[i+1] >= pow)
               {
                  res += pow;
                  arr[i+1] -= pow;
               }
               else
               {
                  res += arr[i+1];
                  arr[i+1] = 0;
               }
            }
         }
         System.out.println(res);
      }
   } import java.util.*; util.* java import java.io.*; io.* java public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N+1];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i <= N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         int[] brr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            brr[i] = Integer.parseInt(st.nextToken());
         long res = 0L;
         for(int i=0; i < N; i++)
         {
            int pow = brr[i];
            if(pow <= arr[i])
            {
               res += pow;
               arr[i] -= pow;
               brr[i] = 0;
            }
            else
            {
               res += arr[i];
               pow -= arr[i];
               arr[i] = 0;
               if(arr[i+1] >= pow)
               {
                  res += pow;
                  arr[i+1] -= pow;
               }
               else
               {
                  res += arr[i+1];
                  arr[i+1] = 0;
               }
            }
         }
         System.out.println(res);
      }
   } Main public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N+1];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i <= N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         int[] brr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            brr[i] = Integer.parseInt(st.nextToken());
         long res = 0L;
         for(int i=0; i < N; i++)
         {
            int pow = brr[i];
            if(pow <= arr[i])
            {
               res += pow;
               arr[i] -= pow;
               brr[i] = 0;
            }
            else
            {
               res += arr[i];
               pow -= arr[i];
               arr[i] = 0;
               if(arr[i+1] >= pow)
               {
                  res += pow;
                  arr[i+1] -= pow;
               }
               else
               {
                  res += arr[i+1];
                  arr[i+1] = 0;
               }
            }
         }
         System.out.println(res);
      } main {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N+1];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i <= N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         int[] brr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            brr[i] = Integer.parseInt(st.nextToken());
         long res = 0L;
         for(int i=0; i < N; i++)
         {
            int pow = brr[i];
            if(pow <= arr[i])
            {
               res += pow;
               arr[i] -= pow;
               brr[i] = 0;
            }
            else
            {
               res += arr[i];
               pow -= arr[i];
               arr[i] = 0;
               if(arr[i+1] >= pow)
               {
                  res += pow;
                  arr[i+1] -= pow;
               }
               else
               {
                  res += arr[i+1];
                  arr[i+1] = 0;
               }
            }
         }
         System.out.println(res);
      } BufferedReader infile = new BufferedReader(new InputStreamReader(System.in)); infile new BufferedReader(new InputStreamReader(System.in)) StringTokenizer st = new StringTokenizer(infile.readLine()); st new StringTokenizer(infile.readLine()) int N = Integer.parseInt(st.nextToken()); N Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st int[] arr = new int[N+1]; arr new int[N+1] N+1 N 1 st = new StringTokenizer(infile.readLine()) st new StringTokenizer(infile.readLine()) for(int i=0; i <= N; i++)
            arr[i] = Integer.parseInt(st.nextToken()); int i=0; int i=0; i 0 i <= N i N i++ i++ i arr[i] = Integer.parseInt(st.nextToken()); arr[i] = Integer.parseInt(st.nextToken()) arr[i] arr i Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st int[] brr = new int[N]; brr new int[N] N st = new StringTokenizer(infile.readLine()) st new StringTokenizer(infile.readLine()) for(int i=0; i < N; i++)
            brr[i] = Integer.parseInt(st.nextToken()); int i=0; int i=0; i 0 i < N i N i++ i++ i brr[i] = Integer.parseInt(st.nextToken()); brr[i] = Integer.parseInt(st.nextToken()) brr[i] brr i Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st long res = 0L; res 0L for(int i=0; i < N; i++)
         {
            int pow = brr[i];
            if(pow <= arr[i])
            {
               res += pow;
               arr[i] -= pow;
               brr[i] = 0;
            }
            else
            {
               res += arr[i];
               pow -= arr[i];
               arr[i] = 0;
               if(arr[i+1] >= pow)
               {
                  res += pow;
                  arr[i+1] -= pow;
               }
               else
               {
                  res += arr[i+1];
                  arr[i+1] = 0;
               }
            }
         } int i=0; int i=0; i 0 i < N i N i++ i++ i {
            int pow = brr[i];
            if(pow <= arr[i])
            {
               res += pow;
               arr[i] -= pow;
               brr[i] = 0;
            }
            else
            {
               res += arr[i];
               pow -= arr[i];
               arr[i] = 0;
               if(arr[i+1] >= pow)
               {
                  res += pow;
                  arr[i+1] -= pow;
               }
               else
               {
                  res += arr[i+1];
                  arr[i+1] = 0;
               }
            }
         } {
            int pow = brr[i];
            if(pow <= arr[i])
            {
               res += pow;
               arr[i] -= pow;
               brr[i] = 0;
            }
            else
            {
               res += arr[i];
               pow -= arr[i];
               arr[i] = 0;
               if(arr[i+1] >= pow)
               {
                  res += pow;
                  arr[i+1] -= pow;
               }
               else
               {
                  res += arr[i+1];
                  arr[i+1] = 0;
               }
            }
         } int pow = brr[i]; pow brr[i] brr i if(pow <= arr[i])
            {
               res += pow;
               arr[i] -= pow;
               brr[i] = 0;
            }
            else
            {
               res += arr[i];
               pow -= arr[i];
               arr[i] = 0;
               if(arr[i+1] >= pow)
               {
                  res += pow;
                  arr[i+1] -= pow;
               }
               else
               {
                  res += arr[i+1];
                  arr[i+1] = 0;
               }
            } pow <= arr[i] pow arr[i] arr i {
               res += pow;
               arr[i] -= pow;
               brr[i] = 0;
            } res += pow res pow arr[i] -= pow arr[i] arr i pow brr[i] = 0 brr[i] brr i 0 {
               res += arr[i];
               pow -= arr[i];
               arr[i] = 0;
               if(arr[i+1] >= pow)
               {
                  res += pow;
                  arr[i+1] -= pow;
               }
               else
               {
                  res += arr[i+1];
                  arr[i+1] = 0;
               }
            } res += arr[i] res arr[i] arr i pow -= arr[i] pow arr[i] arr i arr[i] = 0 arr[i] arr i 0 if(arr[i+1] >= pow)
               {
                  res += pow;
                  arr[i+1] -= pow;
               }
               else
               {
                  res += arr[i+1];
                  arr[i+1] = 0;
               } arr[i+1] >= pow arr[i+1] arr i+1 i 1 pow {
                  res += pow;
                  arr[i+1] -= pow;
               } res += pow res pow arr[i+1] -= pow arr[i+1] arr i+1 i 1 pow {
                  res += arr[i+1];
                  arr[i+1] = 0;
               } res += arr[i+1] res arr[i+1] arr i+1 i 1 arr[i+1] = 0 arr[i+1] arr i+1 i 1 0 System.out.println(res) System.out.println System.out System System.out res String args[] args public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N+1];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i <= N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         int[] brr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            brr[i] = Integer.parseInt(st.nextToken());
         long res = 0L;
         for(int i=0; i < N; i++)
         {
            int pow = brr[i];
            if(pow <= arr[i])
            {
               res += pow;
               arr[i] -= pow;
               brr[i] = 0;
            }
            else
            {
               res += arr[i];
               pow -= arr[i];
               arr[i] = 0;
               if(arr[i+1] >= pow)
               {
                  res += pow;
                  arr[i+1] -= pow;
               }
               else
               {
                  res += arr[i+1];
                  arr[i+1] = 0;
               }
            }
         }
         System.out.println(res);
      }
   } public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N+1];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i <= N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         int[] brr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            brr[i] = Integer.parseInt(st.nextToken());
         long res = 0L;
         for(int i=0; i < N; i++)
         {
            int pow = brr[i];
            if(pow <= arr[i])
            {
               res += pow;
               arr[i] -= pow;
               brr[i] = 0;
            }
            else
            {
               res += arr[i];
               pow -= arr[i];
               arr[i] = 0;
               if(arr[i+1] >= pow)
               {
                  res += pow;
                  arr[i+1] -= pow;
               }
               else
               {
                  res += arr[i+1];
                  arr[i+1] = 0;
               }
            }
         }
         System.out.println(res);
      }
   } Main
/*
Roses are red
Memes are neat
All my test cases time out
Lmao yeet
*/
import java.util.*;
import java.io.*;

   public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N+1];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i <= N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         int[] brr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            brr[i] = Integer.parseInt(st.nextToken());
         long res = 0L;
         for(int i=0; i < N; i++)
         {
            int pow = brr[i];
            if(pow <= arr[i])
            {
               res += pow;
               arr[i] -= pow;
               brr[i] = 0;
            }
            else
            {
               res += arr[i];
               pow -= arr[i];
               arr[i] = 0;
               if(arr[i+1] >= pow)
               {
                  res += pow;
                  arr[i+1] -= pow;
               }
               else
               {
                  res += arr[i+1];
                  arr[i+1] = 0;
               }
            }
         }
         System.out.println(res);
      }
   }