import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int[] a = new int[n + 1];
    int[] b = new int[n + 1];
    for (int i = 0; i < n + 1; i++) {
      a[i] = Integer.parseInt(sc.next());
    }
    for (int i = 0; i < n; i++) {
      b[i] = Integer.parseInt(sc.next());
    }
    b[n] = 0;
    long count = 0;
    int remainB = 0;
    for (int i = 0; i < n + 1; i++) {
      int remainA = Math.max(a[i] - remainB, 0);
      count += Math.min(a[i], remainB);
      remainB = Math.max(b[i] - remainA, 0);
      count += Math.min(remainA, b[i]);
    }
    pw.println(count);
  }
} import java.io.InputStream; InputStream java.io import java.io.PrintStream; PrintStream java.io import java.util.Scanner; Scanner java.util public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int[] a = new int[n + 1];
    int[] b = new int[n + 1];
    for (int i = 0; i < n + 1; i++) {
      a[i] = Integer.parseInt(sc.next());
    }
    for (int i = 0; i < n; i++) {
      b[i] = Integer.parseInt(sc.next());
    }
    b[n] = 0;
    long count = 0;
    int remainB = 0;
    for (int i = 0; i < n + 1; i++) {
      int remainA = Math.max(a[i] - remainB, 0);
      count += Math.min(a[i], remainB);
      remainB = Math.max(b[i] - remainA, 0);
      count += Math.min(remainA, b[i]);
    }
    pw.println(count);
  }
} Main public static void main(String[] args) {
    resolve(System.in, System.out);
  } main {
    resolve(System.in, System.out);
  } resolve(System.in, System.out) resolve System.in System System.in System.out System System.out String[] args args static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int[] a = new int[n + 1];
    int[] b = new int[n + 1];
    for (int i = 0; i < n + 1; i++) {
      a[i] = Integer.parseInt(sc.next());
    }
    for (int i = 0; i < n; i++) {
      b[i] = Integer.parseInt(sc.next());
    }
    b[n] = 0;
    long count = 0;
    int remainB = 0;
    for (int i = 0; i < n + 1; i++) {
      int remainA = Math.max(a[i] - remainB, 0);
      count += Math.min(a[i], remainB);
      remainB = Math.max(b[i] - remainA, 0);
      count += Math.min(remainA, b[i]);
    }
    pw.println(count);
  } resolve {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int[] a = new int[n + 1];
    int[] b = new int[n + 1];
    for (int i = 0; i < n + 1; i++) {
      a[i] = Integer.parseInt(sc.next());
    }
    for (int i = 0; i < n; i++) {
      b[i] = Integer.parseInt(sc.next());
    }
    b[n] = 0;
    long count = 0;
    int remainB = 0;
    for (int i = 0; i < n + 1; i++) {
      int remainA = Math.max(a[i] - remainB, 0);
      count += Math.min(a[i], remainB);
      remainB = Math.max(b[i] - remainA, 0);
      count += Math.min(remainA, b[i]);
    }
    pw.println(count);
  } Scanner sc = new Scanner(is); sc new Scanner(is) 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 + 1]; b new int[n + 1] n + 1 n 1 for (int i = 0; i < n + 1; i++) {
      a[i] = Integer.parseInt(sc.next());
    } 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());
    } {
      a[i] = Integer.parseInt(sc.next());
    } a[i] = Integer.parseInt(sc.next()) a[i] a i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc 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 b[n] = 0 b[n] b n 0 long count = 0; count 0 int remainB = 0; remainB 0 for (int i = 0; i < n + 1; i++) {
      int remainA = Math.max(a[i] - remainB, 0);
      count += Math.min(a[i], remainB);
      remainB = Math.max(b[i] - remainA, 0);
      count += Math.min(remainA, b[i]);
    } int i = 0; int i = 0; i 0 i < n + 1 i n + 1 n 1 i++ i++ i {
      int remainA = Math.max(a[i] - remainB, 0);
      count += Math.min(a[i], remainB);
      remainB = Math.max(b[i] - remainA, 0);
      count += Math.min(remainA, b[i]);
    } {
      int remainA = Math.max(a[i] - remainB, 0);
      count += Math.min(a[i], remainB);
      remainB = Math.max(b[i] - remainA, 0);
      count += Math.min(remainA, b[i]);
    } int remainA = Math.max(a[i] - remainB, 0); remainA Math.max(a[i] - remainB, 0) Math.max Math a[i] - remainB a[i] a i remainB 0 count += Math.min(a[i], remainB) count Math.min(a[i], remainB) Math.min Math a[i] a i remainB remainB = Math.max(b[i] - remainA, 0) remainB Math.max(b[i] - remainA, 0) Math.max Math b[i] - remainA b[i] b i remainA 0 count += Math.min(remainA, b[i]) count Math.min(remainA, b[i]) Math.min Math remainA b[i] b i pw.println(count) pw.println pw count InputStream is is PrintStream pw pw public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int[] a = new int[n + 1];
    int[] b = new int[n + 1];
    for (int i = 0; i < n + 1; i++) {
      a[i] = Integer.parseInt(sc.next());
    }
    for (int i = 0; i < n; i++) {
      b[i] = Integer.parseInt(sc.next());
    }
    b[n] = 0;
    long count = 0;
    int remainB = 0;
    for (int i = 0; i < n + 1; i++) {
      int remainA = Math.max(a[i] - remainB, 0);
      count += Math.min(a[i], remainB);
      remainB = Math.max(b[i] - remainA, 0);
      count += Math.min(remainA, b[i]);
    }
    pw.println(count);
  }
} public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int[] a = new int[n + 1];
    int[] b = new int[n + 1];
    for (int i = 0; i < n + 1; i++) {
      a[i] = Integer.parseInt(sc.next());
    }
    for (int i = 0; i < n; i++) {
      b[i] = Integer.parseInt(sc.next());
    }
    b[n] = 0;
    long count = 0;
    int remainB = 0;
    for (int i = 0; i < n + 1; i++) {
      int remainA = Math.max(a[i] - remainB, 0);
      count += Math.min(a[i], remainB);
      remainB = Math.max(b[i] - remainA, 0);
      count += Math.min(remainA, b[i]);
    }
    pw.println(count);
  }
} Main
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int[] a = new int[n + 1];
    int[] b = new int[n + 1];
    for (int i = 0; i < n + 1; i++) {
      a[i] = Integer.parseInt(sc.next());
    }
    for (int i = 0; i < n; i++) {
      b[i] = Integer.parseInt(sc.next());
    }
    b[n] = 0;
    long count = 0;
    int remainB = 0;
    for (int i = 0; i < n + 1; i++) {
      int remainA = Math.max(a[i] - remainB, 0);
      count += Math.min(a[i], remainB);
      remainB = Math.max(b[i] - remainA, 0);
      count += Math.min(remainA, b[i]);
    }
    pw.println(count);
  }
}
