import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
      long[] a = new long[n+1];
      long[] b = new long[n];
      for(int i=0;i<n+1;i++){
        a[i] = scan.nextLong();
      }
      for(int i=0;i<n;i++){
        b[i] = scan.nextLong();
      }
      
      long result=0;
      for(int i=n-1;i>=0;i--){
        long x = a[i+1]>b[i]?b[i]:a[i+1];
        a[i+1] -= x;
        b[i]-=x;
        result +=x;
        if(b[i]>0){
          long y = a[i]>b[i]?b[i]:a[i];
          a[i] -= y;
          b[i]-=y;
          result +=y;
        }
      }
      System.out.println(result);
	}
} import java.util.*; util.* java class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
      long[] a = new long[n+1];
      long[] b = new long[n];
      for(int i=0;i<n+1;i++){
        a[i] = scan.nextLong();
      }
      for(int i=0;i<n;i++){
        b[i] = scan.nextLong();
      }
      
      long result=0;
      for(int i=n-1;i>=0;i--){
        long x = a[i+1]>b[i]?b[i]:a[i+1];
        a[i+1] -= x;
        b[i]-=x;
        result +=x;
        if(b[i]>0){
          long y = a[i]>b[i]?b[i]:a[i];
          a[i] -= y;
          b[i]-=y;
          result +=y;
        }
      }
      System.out.println(result);
	}
} Main public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
      long[] a = new long[n+1];
      long[] b = new long[n];
      for(int i=0;i<n+1;i++){
        a[i] = scan.nextLong();
      }
      for(int i=0;i<n;i++){
        b[i] = scan.nextLong();
      }
      
      long result=0;
      for(int i=n-1;i>=0;i--){
        long x = a[i+1]>b[i]?b[i]:a[i+1];
        a[i+1] -= x;
        b[i]-=x;
        result +=x;
        if(b[i]>0){
          long y = a[i]>b[i]?b[i]:a[i];
          a[i] -= y;
          b[i]-=y;
          result +=y;
        }
      }
      System.out.println(result);
	} main {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
      long[] a = new long[n+1];
      long[] b = new long[n];
      for(int i=0;i<n+1;i++){
        a[i] = scan.nextLong();
      }
      for(int i=0;i<n;i++){
        b[i] = scan.nextLong();
      }
      
      long result=0;
      for(int i=n-1;i>=0;i--){
        long x = a[i+1]>b[i]?b[i]:a[i+1];
        a[i+1] -= x;
        b[i]-=x;
        result +=x;
        if(b[i]>0){
          long y = a[i]>b[i]?b[i]:a[i];
          a[i] -= y;
          b[i]-=y;
          result +=y;
        }
      }
      System.out.println(result);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan 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 for(int i=0;i<n+1;i++){
        a[i] = scan.nextLong();
      } int i=0; int i=0; i 0 i<n+1 i n+1 n 1 i++ i++ i {
        a[i] = scan.nextLong();
      } {
        a[i] = scan.nextLong();
      } a[i] = scan.nextLong() a[i] a i scan.nextLong() scan.nextLong scan for(int i=0;i<n;i++){
        b[i] = scan.nextLong();
      } int i=0; int i=0; i 0 i<n i n i++ i++ i {
        b[i] = scan.nextLong();
      } {
        b[i] = scan.nextLong();
      } b[i] = scan.nextLong() b[i] b i scan.nextLong() scan.nextLong scan long result=0; result 0 for(int i=n-1;i>=0;i--){
        long x = a[i+1]>b[i]?b[i]:a[i+1];
        a[i+1] -= x;
        b[i]-=x;
        result +=x;
        if(b[i]>0){
          long y = a[i]>b[i]?b[i]:a[i];
          a[i] -= y;
          b[i]-=y;
          result +=y;
        }
      } int i=n-1; int i=n-1; i n-1 n 1 i>=0 i 0 i-- i-- i {
        long x = a[i+1]>b[i]?b[i]:a[i+1];
        a[i+1] -= x;
        b[i]-=x;
        result +=x;
        if(b[i]>0){
          long y = a[i]>b[i]?b[i]:a[i];
          a[i] -= y;
          b[i]-=y;
          result +=y;
        }
      } {
        long x = a[i+1]>b[i]?b[i]:a[i+1];
        a[i+1] -= x;
        b[i]-=x;
        result +=x;
        if(b[i]>0){
          long y = a[i]>b[i]?b[i]:a[i];
          a[i] -= y;
          b[i]-=y;
          result +=y;
        }
      } long x = a[i+1]>b[i]?b[i]:a[i+1]; x a[i+1]>b[i]?b[i]:a[i+1] a[i+1]>b[i] a[i+1] a i+1 i 1 b[i] b i b[i] b i a[i+1] a i+1 i 1 a[i+1] -= x a[i+1] a i+1 i 1 x b[i]-=x b[i] b i x result +=x result x if(b[i]>0){
          long y = a[i]>b[i]?b[i]:a[i];
          a[i] -= y;
          b[i]-=y;
          result +=y;
        } b[i]>0 b[i] b i 0 {
          long y = a[i]>b[i]?b[i]:a[i];
          a[i] -= y;
          b[i]-=y;
          result +=y;
        } long y = a[i]>b[i]?b[i]:a[i]; y a[i]>b[i]?b[i]:a[i] a[i]>b[i] a[i] a i b[i] b i b[i] b i a[i] a i a[i] -= y a[i] a i y b[i]-=y b[i] b i y result +=y result y System.out.println(result) System.out.println System.out System System.out result String args[] args
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
      long[] a = new long[n+1];
      long[] b = new long[n];
      for(int i=0;i<n+1;i++){
        a[i] = scan.nextLong();
      }
      for(int i=0;i<n;i++){
        b[i] = scan.nextLong();
      }
      
      long result=0;
      for(int i=n-1;i>=0;i--){
        long x = a[i+1]>b[i]?b[i]:a[i+1];
        a[i+1] -= x;
        b[i]-=x;
        result +=x;
        if(b[i]>0){
          long y = a[i]>b[i]?b[i]:a[i];
          a[i] -= y;
          b[i]-=y;
          result +=y;
        }
      }
      System.out.println(result);
	}
}