import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    String dummy = sc.nextLine();

    String[] s = sc.nextLine().split(" ");
    String[] t = sc.nextLine().split(" ");
    
    int[] a = new int[n+1];
    int[] b = new int[n];

    for (int i = 0; i < n + 1; i++) {
      a[i] = Integer.parseInt(s[i]);
      if (i < n) b[i] = Integer.parseInt(t[i]);
    }
    
    long sum = 0;
    long rep = 0;
    for (int i = 0; i < n; i++) {
      a[i] -= rep;
      sum += Math.min(a[i] + a[i+1], b[i]);
      if (a[i] > b[i]) {
        rep = 0;
      } else {
        rep = Math.min(b[i] - a[i], a[i+1]);
      }
      // System.out.println("a:" + a[i] + " m:" + m + " rep:" + rep + " sum:" + sum);
    }
    
    System.out.println(sum);
  }
} import java.util.*; util.* java public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    String dummy = sc.nextLine();

    String[] s = sc.nextLine().split(" ");
    String[] t = sc.nextLine().split(" ");
    
    int[] a = new int[n+1];
    int[] b = new int[n];

    for (int i = 0; i < n + 1; i++) {
      a[i] = Integer.parseInt(s[i]);
      if (i < n) b[i] = Integer.parseInt(t[i]);
    }
    
    long sum = 0;
    long rep = 0;
    for (int i = 0; i < n; i++) {
      a[i] -= rep;
      sum += Math.min(a[i] + a[i+1], b[i]);
      if (a[i] > b[i]) {
        rep = 0;
      } else {
        rep = Math.min(b[i] - a[i], a[i+1]);
      }
      // System.out.println("a:" + a[i] + " m:" + m + " rep:" + rep + " sum:" + sum);
    }
    
    System.out.println(sum);
  }
} Main public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    String dummy = sc.nextLine();

    String[] s = sc.nextLine().split(" ");
    String[] t = sc.nextLine().split(" ");
    
    int[] a = new int[n+1];
    int[] b = new int[n];

    for (int i = 0; i < n + 1; i++) {
      a[i] = Integer.parseInt(s[i]);
      if (i < n) b[i] = Integer.parseInt(t[i]);
    }
    
    long sum = 0;
    long rep = 0;
    for (int i = 0; i < n; i++) {
      a[i] -= rep;
      sum += Math.min(a[i] + a[i+1], b[i]);
      if (a[i] > b[i]) {
        rep = 0;
      } else {
        rep = Math.min(b[i] - a[i], a[i+1]);
      }
      // System.out.println("a:" + a[i] + " m:" + m + " rep:" + rep + " sum:" + sum);
    }
    
    System.out.println(sum);
  } main {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    String dummy = sc.nextLine();

    String[] s = sc.nextLine().split(" ");
    String[] t = sc.nextLine().split(" ");
    
    int[] a = new int[n+1];
    int[] b = new int[n];

    for (int i = 0; i < n + 1; i++) {
      a[i] = Integer.parseInt(s[i]);
      if (i < n) b[i] = Integer.parseInt(t[i]);
    }
    
    long sum = 0;
    long rep = 0;
    for (int i = 0; i < n; i++) {
      a[i] -= rep;
      sum += Math.min(a[i] + a[i+1], b[i]);
      if (a[i] > b[i]) {
        rep = 0;
      } else {
        rep = Math.min(b[i] - a[i], a[i+1]);
      }
      // System.out.println("a:" + a[i] + " m:" + m + " rep:" + rep + " sum:" + sum);
    }
    
    System.out.println(sum);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc String dummy = sc.nextLine(); dummy sc.nextLine() sc.nextLine sc String[] s = sc.nextLine().split(" "); s sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " String[] t = sc.nextLine().split(" "); t sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine 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 for (int i = 0; i < n + 1; i++) {
      a[i] = Integer.parseInt(s[i]);
      if (i < n) b[i] = Integer.parseInt(t[i]);
    } int i = 0; int i = 0; i 0 i < n + 1 i n + 1 n 1 i++ i++ i {
      a[i] = Integer.parseInt(s[i]);
      if (i < n) b[i] = Integer.parseInt(t[i]);
    } {
      a[i] = Integer.parseInt(s[i]);
      if (i < n) b[i] = Integer.parseInt(t[i]);
    } a[i] = Integer.parseInt(s[i]) a[i] a i Integer.parseInt(s[i]) Integer.parseInt Integer s[i] s i if (i < n) b[i] = Integer.parseInt(t[i]); i < n i n b[i] = Integer.parseInt(t[i]) b[i] b i Integer.parseInt(t[i]) Integer.parseInt Integer t[i] t i long sum = 0; sum 0 long rep = 0; rep 0 for (int i = 0; i < n; i++) {
      a[i] -= rep;
      sum += Math.min(a[i] + a[i+1], b[i]);
      if (a[i] > b[i]) {
        rep = 0;
      } else {
        rep = Math.min(b[i] - a[i], a[i+1]);
      }
      // System.out.println("a:" + a[i] + " m:" + m + " rep:" + rep + " sum:" + sum);
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      a[i] -= rep;
      sum += Math.min(a[i] + a[i+1], b[i]);
      if (a[i] > b[i]) {
        rep = 0;
      } else {
        rep = Math.min(b[i] - a[i], a[i+1]);
      }
      // System.out.println("a:" + a[i] + " m:" + m + " rep:" + rep + " sum:" + sum);
    } {
      a[i] -= rep;
      sum += Math.min(a[i] + a[i+1], b[i]);
      if (a[i] > b[i]) {
        rep = 0;
      } else {
        rep = Math.min(b[i] - a[i], a[i+1]);
      }
      // System.out.println("a:" + a[i] + " m:" + m + " rep:" + rep + " sum:" + sum);
    } a[i] -= rep a[i] a i rep sum += Math.min(a[i] + a[i+1], b[i]) sum Math.min(a[i] + a[i+1], b[i]) Math.min Math a[i] + a[i+1] a[i] a i a[i+1] a i+1 i 1 b[i] b i if (a[i] > b[i]) {
        rep = 0;
      } else {
        rep = Math.min(b[i] - a[i], a[i+1]);
      } a[i] > b[i] a[i] a i b[i] b i {
        rep = 0;
      } rep = 0 rep 0 {
        rep = Math.min(b[i] - a[i], a[i+1]);
      } rep = Math.min(b[i] - a[i], a[i+1]) rep Math.min(b[i] - a[i], a[i+1]) Math.min Math b[i] - a[i] b[i] b i a[i] a i a[i+1] a i+1 i 1 System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    String dummy = sc.nextLine();

    String[] s = sc.nextLine().split(" ");
    String[] t = sc.nextLine().split(" ");
    
    int[] a = new int[n+1];
    int[] b = new int[n];

    for (int i = 0; i < n + 1; i++) {
      a[i] = Integer.parseInt(s[i]);
      if (i < n) b[i] = Integer.parseInt(t[i]);
    }
    
    long sum = 0;
    long rep = 0;
    for (int i = 0; i < n; i++) {
      a[i] -= rep;
      sum += Math.min(a[i] + a[i+1], b[i]);
      if (a[i] > b[i]) {
        rep = 0;
      } else {
        rep = Math.min(b[i] - a[i], a[i+1]);
      }
      // System.out.println("a:" + a[i] + " m:" + m + " rep:" + rep + " sum:" + sum);
    }
    
    System.out.println(sum);
  }
} public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    String dummy = sc.nextLine();

    String[] s = sc.nextLine().split(" ");
    String[] t = sc.nextLine().split(" ");
    
    int[] a = new int[n+1];
    int[] b = new int[n];

    for (int i = 0; i < n + 1; i++) {
      a[i] = Integer.parseInt(s[i]);
      if (i < n) b[i] = Integer.parseInt(t[i]);
    }
    
    long sum = 0;
    long rep = 0;
    for (int i = 0; i < n; i++) {
      a[i] -= rep;
      sum += Math.min(a[i] + a[i+1], b[i]);
      if (a[i] > b[i]) {
        rep = 0;
      } else {
        rep = Math.min(b[i] - a[i], a[i+1]);
      }
      // System.out.println("a:" + a[i] + " m:" + m + " rep:" + rep + " sum:" + sum);
    }
    
    System.out.println(sum);
  }
} Main
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    String dummy = sc.nextLine();

    String[] s = sc.nextLine().split(" ");
    String[] t = sc.nextLine().split(" ");
    
    int[] a = new int[n+1];
    int[] b = new int[n];

    for (int i = 0; i < n + 1; i++) {
      a[i] = Integer.parseInt(s[i]);
      if (i < n) b[i] = Integer.parseInt(t[i]);
    }
    
    long sum = 0;
    long rep = 0;
    for (int i = 0; i < n; i++) {
      a[i] -= rep;
      sum += Math.min(a[i] + a[i+1], b[i]);
      if (a[i] > b[i]) {
        rep = 0;
      } else {
        rep = Math.min(b[i] - a[i], a[i+1]);
      }
      // System.out.println("a:" + a[i] + " m:" + m + " rep:" + rep + " sum:" + sum);
    }
    
    System.out.println(sum);
  }
}
