import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();

    long[] a = new long[n + 1];
    long[] b = new long[n];

    for (int i = 0; i <= n; i++)
      a[i] = sc.nextLong();

    b[0] = sc.nextLong();
    long res = Math.min(a[0], b[0]);
    long carry = Math.min(a[1], b[0] - res);
    res += carry;

    for (int i = 1; i < n; i++) {
      b[i] = sc.nextLong();
      long fii = Math.min(a[i] - carry, b[i]);
      carry = Math.min(a[i + 1], b[i] - fii);
      res += fii + carry;
    }

    System.out.println(res);
  }
} import java.util.Scanner; Scanner java.util public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();

    long[] a = new long[n + 1];
    long[] b = new long[n];

    for (int i = 0; i <= n; i++)
      a[i] = sc.nextLong();

    b[0] = sc.nextLong();
    long res = Math.min(a[0], b[0]);
    long carry = Math.min(a[1], b[0] - res);
    res += carry;

    for (int i = 1; i < n; i++) {
      b[i] = sc.nextLong();
      long fii = Math.min(a[i] - carry, b[i]);
      carry = Math.min(a[i + 1], b[i] - fii);
      res += fii + carry;
    }

    System.out.println(res);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();

    long[] a = new long[n + 1];
    long[] b = new long[n];

    for (int i = 0; i <= n; i++)
      a[i] = sc.nextLong();

    b[0] = sc.nextLong();
    long res = Math.min(a[0], b[0]);
    long carry = Math.min(a[1], b[0] - res);
    res += carry;

    for (int i = 1; i < n; i++) {
      b[i] = sc.nextLong();
      long fii = Math.min(a[i] - carry, b[i]);
      carry = Math.min(a[i + 1], b[i] - fii);
      res += fii + carry;
    }

    System.out.println(res);
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();

    long[] a = new long[n + 1];
    long[] b = new long[n];

    for (int i = 0; i <= n; i++)
      a[i] = sc.nextLong();

    b[0] = sc.nextLong();
    long res = Math.min(a[0], b[0]);
    long carry = Math.min(a[1], b[0] - res);
    res += carry;

    for (int i = 1; i < n; i++) {
      b[i] = sc.nextLong();
      long fii = Math.min(a[i] - carry, b[i]);
      carry = Math.min(a[i + 1], b[i] - fii);
      res += fii + carry;
    }

    System.out.println(res);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc 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; i++)
      a[i] = sc.nextLong(); int i = 0; int i = 0; i 0 i <= n i n i++ i++ i a[i] = sc.nextLong(); a[i] = sc.nextLong() a[i] a i sc.nextLong() sc.nextLong sc b[0] = sc.nextLong() b[0] b 0 sc.nextLong() sc.nextLong sc long res = Math.min(a[0], b[0]); res Math.min(a[0], b[0]) Math.min Math a[0] a 0 b[0] b 0 long carry = Math.min(a[1], b[0] - res); carry Math.min(a[1], b[0] - res) Math.min Math a[1] a 1 b[0] - res b[0] b 0 res res += carry res carry for (int i = 1; i < n; i++) {
      b[i] = sc.nextLong();
      long fii = Math.min(a[i] - carry, b[i]);
      carry = Math.min(a[i + 1], b[i] - fii);
      res += fii + carry;
    } int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
      b[i] = sc.nextLong();
      long fii = Math.min(a[i] - carry, b[i]);
      carry = Math.min(a[i + 1], b[i] - fii);
      res += fii + carry;
    } {
      b[i] = sc.nextLong();
      long fii = Math.min(a[i] - carry, b[i]);
      carry = Math.min(a[i + 1], b[i] - fii);
      res += fii + carry;
    } b[i] = sc.nextLong() b[i] b i sc.nextLong() sc.nextLong sc long fii = Math.min(a[i] - carry, b[i]); fii Math.min(a[i] - carry, b[i]) Math.min Math a[i] - carry a[i] a i carry b[i] b i carry = Math.min(a[i + 1], b[i] - fii) carry Math.min(a[i + 1], b[i] - fii) Math.min Math a[i + 1] a i + 1 i 1 b[i] - fii b[i] b i fii res += fii + carry res fii + carry fii carry System.out.println(res) System.out.println System.out System System.out res String[] args args public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();

    long[] a = new long[n + 1];
    long[] b = new long[n];

    for (int i = 0; i <= n; i++)
      a[i] = sc.nextLong();

    b[0] = sc.nextLong();
    long res = Math.min(a[0], b[0]);
    long carry = Math.min(a[1], b[0] - res);
    res += carry;

    for (int i = 1; i < n; i++) {
      b[i] = sc.nextLong();
      long fii = Math.min(a[i] - carry, b[i]);
      carry = Math.min(a[i + 1], b[i] - fii);
      res += fii + carry;
    }

    System.out.println(res);
  }
} public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();

    long[] a = new long[n + 1];
    long[] b = new long[n];

    for (int i = 0; i <= n; i++)
      a[i] = sc.nextLong();

    b[0] = sc.nextLong();
    long res = Math.min(a[0], b[0]);
    long carry = Math.min(a[1], b[0] - res);
    res += carry;

    for (int i = 1; i < n; i++) {
      b[i] = sc.nextLong();
      long fii = Math.min(a[i] - carry, b[i]);
      carry = Math.min(a[i + 1], b[i] - fii);
      res += fii + carry;
    }

    System.out.println(res);
  }
} Main
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();

    long[] a = new long[n + 1];
    long[] b = new long[n];

    for (int i = 0; i <= n; i++)
      a[i] = sc.nextLong();

    b[0] = sc.nextLong();
    long res = Math.min(a[0], b[0]);
    long carry = Math.min(a[1], b[0] - res);
    res += carry;

    for (int i = 1; i < n; i++) {
      b[i] = sc.nextLong();
      long fii = Math.min(a[i] - carry, b[i]);
      carry = Math.min(a[i + 1], b[i] - fii);
      res += fii + carry;
    }

    System.out.println(res);
  }
}