import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	int n = Integer.parseInt(sc.next());
    int a[] = new int[n+1];
    int b[] = new int[n];
    long sb = 0;
    long sa = 0;
    
    for (int i=0; i<n+1; i++){
      a[i] = Integer.parseInt(sc.next());
      sb += a[i];
    }
    for (int i=0; i<n; i++){
      b[i] = Integer.parseInt(sc.next());
    }

    for(int i=0; i<n; i++){
      if (b[i] >= a[i]) {
        b[i] -= a[i];
        a[i] = 0;
        if (b[i] >= a[i+1]) {
          b[i] -= a[i+1];
          a[i+1] = 0;
        } else {
          a[i+1] -= b[i];
          b[i] = 0;
        }
      } else {
        a[i] -= b[i];
        b[i] = 0;
      }
    }
    
    for (int i=0; i<n+1; i++){
      sa += a[i];
    }
    
	System.out.println(sb-sa);


  }
} import java.util.*; util.* java class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	int n = Integer.parseInt(sc.next());
    int a[] = new int[n+1];
    int b[] = new int[n];
    long sb = 0;
    long sa = 0;
    
    for (int i=0; i<n+1; i++){
      a[i] = Integer.parseInt(sc.next());
      sb += a[i];
    }
    for (int i=0; i<n; i++){
      b[i] = Integer.parseInt(sc.next());
    }

    for(int i=0; i<n; i++){
      if (b[i] >= a[i]) {
        b[i] -= a[i];
        a[i] = 0;
        if (b[i] >= a[i+1]) {
          b[i] -= a[i+1];
          a[i+1] = 0;
        } else {
          a[i+1] -= b[i];
          b[i] = 0;
        }
      } else {
        a[i] -= b[i];
        b[i] = 0;
      }
    }
    
    for (int i=0; i<n+1; i++){
      sa += a[i];
    }
    
	System.out.println(sb-sa);


  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	int n = Integer.parseInt(sc.next());
    int a[] = new int[n+1];
    int b[] = new int[n];
    long sb = 0;
    long sa = 0;
    
    for (int i=0; i<n+1; i++){
      a[i] = Integer.parseInt(sc.next());
      sb += a[i];
    }
    for (int i=0; i<n; i++){
      b[i] = Integer.parseInt(sc.next());
    }

    for(int i=0; i<n; i++){
      if (b[i] >= a[i]) {
        b[i] -= a[i];
        a[i] = 0;
        if (b[i] >= a[i+1]) {
          b[i] -= a[i+1];
          a[i+1] = 0;
        } else {
          a[i+1] -= b[i];
          b[i] = 0;
        }
      } else {
        a[i] -= b[i];
        b[i] = 0;
      }
    }
    
    for (int i=0; i<n+1; i++){
      sa += a[i];
    }
    
	System.out.println(sb-sa);


  } main {
    Scanner sc = new Scanner(System.in);
	int n = Integer.parseInt(sc.next());
    int a[] = new int[n+1];
    int b[] = new int[n];
    long sb = 0;
    long sa = 0;
    
    for (int i=0; i<n+1; i++){
      a[i] = Integer.parseInt(sc.next());
      sb += a[i];
    }
    for (int i=0; i<n; i++){
      b[i] = Integer.parseInt(sc.next());
    }

    for(int i=0; i<n; i++){
      if (b[i] >= a[i]) {
        b[i] -= a[i];
        a[i] = 0;
        if (b[i] >= a[i+1]) {
          b[i] -= a[i+1];
          a[i+1] = 0;
        } else {
          a[i+1] -= b[i];
          b[i] = 0;
        }
      } else {
        a[i] -= b[i];
        b[i] = 0;
      }
    }
    
    for (int i=0; i<n+1; i++){
      sa += a[i];
    }
    
	System.out.println(sb-sa);


  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next 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 sb = 0; sb 0 long sa = 0; sa 0 for (int i=0; i<n+1; i++){
      a[i] = Integer.parseInt(sc.next());
      sb += a[i];
    } int i=0; int i=0; i 0 i<n+1 i n+1 n 1 i++ i++ i {
      a[i] = Integer.parseInt(sc.next());
      sb += a[i];
    } {
      a[i] = Integer.parseInt(sc.next());
      sb += a[i];
    } a[i] = Integer.parseInt(sc.next()) a[i] a i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc sb += a[i] sb a[i] a i for (int i=0; i<n; i++){
      b[i] = Integer.parseInt(sc.next());
    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
      b[i] = Integer.parseInt(sc.next());
    } {
      b[i] = Integer.parseInt(sc.next());
    } b[i] = Integer.parseInt(sc.next()) b[i] b i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc for(int i=0; i<n; i++){
      if (b[i] >= a[i]) {
        b[i] -= a[i];
        a[i] = 0;
        if (b[i] >= a[i+1]) {
          b[i] -= a[i+1];
          a[i+1] = 0;
        } else {
          a[i+1] -= b[i];
          b[i] = 0;
        }
      } else {
        a[i] -= b[i];
        b[i] = 0;
      }
    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
      if (b[i] >= a[i]) {
        b[i] -= a[i];
        a[i] = 0;
        if (b[i] >= a[i+1]) {
          b[i] -= a[i+1];
          a[i+1] = 0;
        } else {
          a[i+1] -= b[i];
          b[i] = 0;
        }
      } else {
        a[i] -= b[i];
        b[i] = 0;
      }
    } {
      if (b[i] >= a[i]) {
        b[i] -= a[i];
        a[i] = 0;
        if (b[i] >= a[i+1]) {
          b[i] -= a[i+1];
          a[i+1] = 0;
        } else {
          a[i+1] -= b[i];
          b[i] = 0;
        }
      } else {
        a[i] -= b[i];
        b[i] = 0;
      }
    } if (b[i] >= a[i]) {
        b[i] -= a[i];
        a[i] = 0;
        if (b[i] >= a[i+1]) {
          b[i] -= a[i+1];
          a[i+1] = 0;
        } else {
          a[i+1] -= b[i];
          b[i] = 0;
        }
      } else {
        a[i] -= b[i];
        b[i] = 0;
      } b[i] >= a[i] b[i] b i a[i] a i {
        b[i] -= a[i];
        a[i] = 0;
        if (b[i] >= a[i+1]) {
          b[i] -= a[i+1];
          a[i+1] = 0;
        } else {
          a[i+1] -= b[i];
          b[i] = 0;
        }
      } b[i] -= a[i] b[i] b i a[i] a i a[i] = 0 a[i] a i 0 if (b[i] >= a[i+1]) {
          b[i] -= a[i+1];
          a[i+1] = 0;
        } else {
          a[i+1] -= b[i];
          b[i] = 0;
        } b[i] >= a[i+1] b[i] b i a[i+1] a i+1 i 1 {
          b[i] -= a[i+1];
          a[i+1] = 0;
        } b[i] -= a[i+1] b[i] b i a[i+1] a i+1 i 1 a[i+1] = 0 a[i+1] a i+1 i 1 0 {
          a[i+1] -= b[i];
          b[i] = 0;
        } a[i+1] -= b[i] a[i+1] a i+1 i 1 b[i] b i b[i] = 0 b[i] b i 0 {
        a[i] -= b[i];
        b[i] = 0;
      } a[i] -= b[i] a[i] a i b[i] b i b[i] = 0 b[i] b i 0 for (int i=0; i<n+1; i++){
      sa += a[i];
    } int i=0; int i=0; i 0 i<n+1 i n+1 n 1 i++ i++ i {
      sa += a[i];
    } {
      sa += a[i];
    } sa += a[i] sa a[i] a i System.out.println(sb-sa) System.out.println System.out System System.out sb-sa sb sa String[] args args
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	int n = Integer.parseInt(sc.next());
    int a[] = new int[n+1];
    int b[] = new int[n];
    long sb = 0;
    long sa = 0;
    
    for (int i=0; i<n+1; i++){
      a[i] = Integer.parseInt(sc.next());
      sb += a[i];
    }
    for (int i=0; i<n; i++){
      b[i] = Integer.parseInt(sc.next());
    }

    for(int i=0; i<n; i++){
      if (b[i] >= a[i]) {
        b[i] -= a[i];
        a[i] = 0;
        if (b[i] >= a[i+1]) {
          b[i] -= a[i+1];
          a[i+1] = 0;
        } else {
          a[i+1] -= b[i];
          b[i] = 0;
        }
      } else {
        a[i] -= b[i];
        b[i] = 0;
      }
    }
    
    for (int i=0; i<n+1; i++){
      sa += a[i];
    }
    
	System.out.println(sb-sa);


  }
}
