import java.io.*; 
import java.util.*; 

public class Main{ 
	
	static class FastReader{ 
		BufferedReader br; 
		StringTokenizer st; 

		public FastReader() 
		{ 
			br = new BufferedReader(new
					InputStreamReader(System.in)); 
		} 

		String next() 
		{ 
			while (st == null || !st.hasMoreElements()) 
			{ 
				try
				{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException e) 
				{ 
					e.printStackTrace(); 
				} 
			} 
			return st.nextToken(); 
		} 

		int nextInt() 
		{ 
			return Integer.parseInt(next()); 
		} 

		long nextLong() 
		{ 
			return Long.parseLong(next()); 
		} 

		double nextDouble() 
		{ 
			return Double.parseDouble(next()); 
		} 

		String nextLine() 
		{ 
			String str = ""; 
			try
			{ 
				str = br.readLine(); 
			} 
			catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} 
			return str; 
		} 
	}
  
	public static void main(String[] args) 
	{ 
		FastReader sc = new FastReader(); 
		int n = sc.nextInt();
      	long[] arr = new long[n+1], brr = new long[n];
      	long res = 0;
      	for(int i=0;i<=n;i++){
           	arr[i] = sc.nextLong();
          	res+=arr[i];
        }
      	
      	for(int j=0;j<n;j++)
          	brr[j] = sc.nextLong();
		
      	for(int i=n-1;i>=0;i--){
          	long temp = Math.min(brr[i], arr[i+1]);
          	brr[i]-=temp;
          	arr[i+1]-=temp;
          	arr[i] -= Math.min(arr[i], brr[i]);
          	
          	res-=arr[i+1];
        }
      	res-=arr[0];
      	System.out.println(res); 
	}
} import java.io.*; io.* java import java.util.*; util.* java public class Main{ 
	
	static class FastReader{ 
		BufferedReader br; 
		StringTokenizer st; 

		public FastReader() 
		{ 
			br = new BufferedReader(new
					InputStreamReader(System.in)); 
		} 

		String next() 
		{ 
			while (st == null || !st.hasMoreElements()) 
			{ 
				try
				{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException e) 
				{ 
					e.printStackTrace(); 
				} 
			} 
			return st.nextToken(); 
		} 

		int nextInt() 
		{ 
			return Integer.parseInt(next()); 
		} 

		long nextLong() 
		{ 
			return Long.parseLong(next()); 
		} 

		double nextDouble() 
		{ 
			return Double.parseDouble(next()); 
		} 

		String nextLine() 
		{ 
			String str = ""; 
			try
			{ 
				str = br.readLine(); 
			} 
			catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} 
			return str; 
		} 
	}
  
	public static void main(String[] args) 
	{ 
		FastReader sc = new FastReader(); 
		int n = sc.nextInt();
      	long[] arr = new long[n+1], brr = new long[n];
      	long res = 0;
      	for(int i=0;i<=n;i++){
           	arr[i] = sc.nextLong();
          	res+=arr[i];
        }
      	
      	for(int j=0;j<n;j++)
          	brr[j] = sc.nextLong();
		
      	for(int i=n-1;i>=0;i--){
          	long temp = Math.min(brr[i], arr[i+1]);
          	brr[i]-=temp;
          	arr[i+1]-=temp;
          	arr[i] -= Math.min(arr[i], brr[i]);
          	
          	res-=arr[i+1];
        }
      	res-=arr[0];
      	System.out.println(res); 
	}
} Main public static void main(String[] args) 
	{ 
		FastReader sc = new FastReader(); 
		int n = sc.nextInt();
      	long[] arr = new long[n+1], brr = new long[n];
      	long res = 0;
      	for(int i=0;i<=n;i++){
           	arr[i] = sc.nextLong();
          	res+=arr[i];
        }
      	
      	for(int j=0;j<n;j++)
          	brr[j] = sc.nextLong();
		
      	for(int i=n-1;i>=0;i--){
          	long temp = Math.min(brr[i], arr[i+1]);
          	brr[i]-=temp;
          	arr[i+1]-=temp;
          	arr[i] -= Math.min(arr[i], brr[i]);
          	
          	res-=arr[i+1];
        }
      	res-=arr[0];
      	System.out.println(res); 
	} main { 
		FastReader sc = new FastReader(); 
		int n = sc.nextInt();
      	long[] arr = new long[n+1], brr = new long[n];
      	long res = 0;
      	for(int i=0;i<=n;i++){
           	arr[i] = sc.nextLong();
          	res+=arr[i];
        }
      	
      	for(int j=0;j<n;j++)
          	brr[j] = sc.nextLong();
		
      	for(int i=n-1;i>=0;i--){
          	long temp = Math.min(brr[i], arr[i+1]);
          	brr[i]-=temp;
          	arr[i+1]-=temp;
          	arr[i] -= Math.min(arr[i], brr[i]);
          	
          	res-=arr[i+1];
        }
      	res-=arr[0];
      	System.out.println(res); 
	} FastReader sc = new FastReader(); sc new FastReader() int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc long[] arr = new long[n+1] arr new long[n+1] n+1 n 1 brr = new long[n]; brr new long[n] n long res = 0; res 0 for(int i=0;i<=n;i++){
           	arr[i] = sc.nextLong();
          	res+=arr[i];
        } int i=0; int i=0; i 0 i<=n i n i++ i++ i {
           	arr[i] = sc.nextLong();
          	res+=arr[i];
        } {
           	arr[i] = sc.nextLong();
          	res+=arr[i];
        } arr[i] = sc.nextLong() arr[i] arr i sc.nextLong() sc.nextLong sc res+=arr[i] res arr[i] arr i for(int j=0;j<n;j++)
          	brr[j] = sc.nextLong(); int j=0; int j=0; j 0 j<n j n j++ j++ j brr[j] = sc.nextLong(); brr[j] = sc.nextLong() brr[j] brr j sc.nextLong() sc.nextLong sc for(int i=n-1;i>=0;i--){
          	long temp = Math.min(brr[i], arr[i+1]);
          	brr[i]-=temp;
          	arr[i+1]-=temp;
          	arr[i] -= Math.min(arr[i], brr[i]);
          	
          	res-=arr[i+1];
        } int i=n-1; int i=n-1; i n-1 n 1 i>=0 i 0 i-- i-- i {
          	long temp = Math.min(brr[i], arr[i+1]);
          	brr[i]-=temp;
          	arr[i+1]-=temp;
          	arr[i] -= Math.min(arr[i], brr[i]);
          	
          	res-=arr[i+1];
        } {
          	long temp = Math.min(brr[i], arr[i+1]);
          	brr[i]-=temp;
          	arr[i+1]-=temp;
          	arr[i] -= Math.min(arr[i], brr[i]);
          	
          	res-=arr[i+1];
        } long temp = Math.min(brr[i], arr[i+1]); temp Math.min(brr[i], arr[i+1]) Math.min Math brr[i] brr i arr[i+1] arr i+1 i 1 brr[i]-=temp brr[i] brr i temp arr[i+1]-=temp arr[i+1] arr i+1 i 1 temp arr[i] -= Math.min(arr[i], brr[i]) arr[i] arr i Math.min(arr[i], brr[i]) Math.min Math arr[i] arr i brr[i] brr i res-=arr[i+1] res arr[i+1] arr i+1 i 1 res-=arr[0] res arr[0] arr 0 System.out.println(res) System.out.println System.out System System.out res String[] args args static class FastReader{ 
		BufferedReader br; 
		StringTokenizer st; 

		public FastReader() 
		{ 
			br = new BufferedReader(new
					InputStreamReader(System.in)); 
		} 

		String next() 
		{ 
			while (st == null || !st.hasMoreElements()) 
			{ 
				try
				{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException e) 
				{ 
					e.printStackTrace(); 
				} 
			} 
			return st.nextToken(); 
		} 

		int nextInt() 
		{ 
			return Integer.parseInt(next()); 
		} 

		long nextLong() 
		{ 
			return Long.parseLong(next()); 
		} 

		double nextDouble() 
		{ 
			return Double.parseDouble(next()); 
		} 

		String nextLine() 
		{ 
			String str = ""; 
			try
			{ 
				str = br.readLine(); 
			} 
			catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} 
			return str; 
		} 
	} FastReader BufferedReader br; br StringTokenizer st; st public FastReader() 
		{ 
			br = new BufferedReader(new
					InputStreamReader(System.in)); 
		} FastReader { 
			br = new BufferedReader(new
					InputStreamReader(System.in)); 
		} br = new BufferedReader(new
					InputStreamReader(System.in)) br new BufferedReader(new
					InputStreamReader(System.in)) String next() 
		{ 
			while (st == null || !st.hasMoreElements()) 
			{ 
				try
				{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException e) 
				{ 
					e.printStackTrace(); 
				} 
			} 
			return st.nextToken(); 
		} next { 
			while (st == null || !st.hasMoreElements()) 
			{ 
				try
				{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException e) 
				{ 
					e.printStackTrace(); 
				} 
			} 
			return st.nextToken(); 
		} while (st == null || !st.hasMoreElements()) 
			{ 
				try
				{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException e) 
				{ 
					e.printStackTrace(); 
				} 
			} st == null || !st.hasMoreElements() st == null st null !st.hasMoreElements() st.hasMoreElements() st.hasMoreElements st { 
				try
				{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException e) 
				{ 
					e.printStackTrace(); 
				} 
			} try
				{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException e) 
				{ 
					e.printStackTrace(); 
				} catch (IOException e) 
				{ 
					e.printStackTrace(); 
				} IOException e { 
					e.printStackTrace(); 
				} e.printStackTrace() e.printStackTrace e { 
					st = new StringTokenizer(br.readLine()); 
				} st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st int nextInt() 
		{ 
			return Integer.parseInt(next()); 
		} nextInt { 
			return Integer.parseInt(next()); 
		} return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next long nextLong() 
		{ 
			return Long.parseLong(next()); 
		} nextLong { 
			return Long.parseLong(next()); 
		} return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next double nextDouble() 
		{ 
			return Double.parseDouble(next()); 
		} nextDouble { 
			return Double.parseDouble(next()); 
		} return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next String nextLine() 
		{ 
			String str = ""; 
			try
			{ 
				str = br.readLine(); 
			} 
			catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} 
			return str; 
		} nextLine { 
			String str = ""; 
			try
			{ 
				str = br.readLine(); 
			} 
			catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} 
			return str; 
		} String str = ""; str "" try
			{ 
				str = br.readLine(); 
			} 
			catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} IOException e { 
				e.printStackTrace(); 
			} e.printStackTrace() e.printStackTrace e { 
				str = br.readLine(); 
			} str = br.readLine() str br.readLine() br.readLine br return str; str public class Main{ 
	
	static class FastReader{ 
		BufferedReader br; 
		StringTokenizer st; 

		public FastReader() 
		{ 
			br = new BufferedReader(new
					InputStreamReader(System.in)); 
		} 

		String next() 
		{ 
			while (st == null || !st.hasMoreElements()) 
			{ 
				try
				{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException e) 
				{ 
					e.printStackTrace(); 
				} 
			} 
			return st.nextToken(); 
		} 

		int nextInt() 
		{ 
			return Integer.parseInt(next()); 
		} 

		long nextLong() 
		{ 
			return Long.parseLong(next()); 
		} 

		double nextDouble() 
		{ 
			return Double.parseDouble(next()); 
		} 

		String nextLine() 
		{ 
			String str = ""; 
			try
			{ 
				str = br.readLine(); 
			} 
			catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} 
			return str; 
		} 
	}
  
	public static void main(String[] args) 
	{ 
		FastReader sc = new FastReader(); 
		int n = sc.nextInt();
      	long[] arr = new long[n+1], brr = new long[n];
      	long res = 0;
      	for(int i=0;i<=n;i++){
           	arr[i] = sc.nextLong();
          	res+=arr[i];
        }
      	
      	for(int j=0;j<n;j++)
          	brr[j] = sc.nextLong();
		
      	for(int i=n-1;i>=0;i--){
          	long temp = Math.min(brr[i], arr[i+1]);
          	brr[i]-=temp;
          	arr[i+1]-=temp;
          	arr[i] -= Math.min(arr[i], brr[i]);
          	
          	res-=arr[i+1];
        }
      	res-=arr[0];
      	System.out.println(res); 
	}
} public class Main{ 
	
	static class FastReader{ 
		BufferedReader br; 
		StringTokenizer st; 

		public FastReader() 
		{ 
			br = new BufferedReader(new
					InputStreamReader(System.in)); 
		} 

		String next() 
		{ 
			while (st == null || !st.hasMoreElements()) 
			{ 
				try
				{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException e) 
				{ 
					e.printStackTrace(); 
				} 
			} 
			return st.nextToken(); 
		} 

		int nextInt() 
		{ 
			return Integer.parseInt(next()); 
		} 

		long nextLong() 
		{ 
			return Long.parseLong(next()); 
		} 

		double nextDouble() 
		{ 
			return Double.parseDouble(next()); 
		} 

		String nextLine() 
		{ 
			String str = ""; 
			try
			{ 
				str = br.readLine(); 
			} 
			catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} 
			return str; 
		} 
	}
  
	public static void main(String[] args) 
	{ 
		FastReader sc = new FastReader(); 
		int n = sc.nextInt();
      	long[] arr = new long[n+1], brr = new long[n];
      	long res = 0;
      	for(int i=0;i<=n;i++){
           	arr[i] = sc.nextLong();
          	res+=arr[i];
        }
      	
      	for(int j=0;j<n;j++)
          	brr[j] = sc.nextLong();
		
      	for(int i=n-1;i>=0;i--){
          	long temp = Math.min(brr[i], arr[i+1]);
          	brr[i]-=temp;
          	arr[i+1]-=temp;
          	arr[i] -= Math.min(arr[i], brr[i]);
          	
          	res-=arr[i+1];
        }
      	res-=arr[0];
      	System.out.println(res); 
	}
} Main
import java.io.*; 
import java.util.*; 

public class Main{ 
	
	static class FastReader{ 
		BufferedReader br; 
		StringTokenizer st; 

		public FastReader() 
		{ 
			br = new BufferedReader(new
					InputStreamReader(System.in)); 
		} 

		String next() 
		{ 
			while (st == null || !st.hasMoreElements()) 
			{ 
				try
				{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException e) 
				{ 
					e.printStackTrace(); 
				} 
			} 
			return st.nextToken(); 
		} 

		int nextInt() 
		{ 
			return Integer.parseInt(next()); 
		} 

		long nextLong() 
		{ 
			return Long.parseLong(next()); 
		} 

		double nextDouble() 
		{ 
			return Double.parseDouble(next()); 
		} 

		String nextLine() 
		{ 
			String str = ""; 
			try
			{ 
				str = br.readLine(); 
			} 
			catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} 
			return str; 
		} 
	}
  
	public static void main(String[] args) 
	{ 
		FastReader sc = new FastReader(); 
		int n = sc.nextInt();
      	long[] arr = new long[n+1], brr = new long[n];
      	long res = 0;
      	for(int i=0;i<=n;i++){
           	arr[i] = sc.nextLong();
          	res+=arr[i];
        }
      	
      	for(int j=0;j<n;j++)
          	brr[j] = sc.nextLong();
		
      	for(int i=n-1;i>=0;i--){
          	long temp = Math.min(brr[i], arr[i+1]);
          	brr[i]-=temp;
          	arr[i+1]-=temp;
          	arr[i] -= Math.min(arr[i], brr[i]);
          	
          	res-=arr[i+1];
        }
      	res-=arr[0];
      	System.out.println(res); 
	}
}
