import java.util.Scanner;

/**
 * https://atcoder.jp/contests/abc135/tasks/abc135_c
 */
public class Main {

  private static long answer(long[] mons, long[] heroes) {
    long remain = mons[0];
    long sum = 0;
    for (int i = 0; i < heroes.length; i++) {
      long killed = Math.min(heroes[i], remain);
      long killed2 = Math.min(heroes[i] - killed, mons[i + 1]);
      remain = mons[i + 1] - killed2;
      sum += killed + killed2;
    }

    return sum;
  }

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    long[] mons = new long[n+1];
    long[] heroes = new long[n];
    for (int i = 0; i < n + 1; i++) {
      mons[i] = scan.nextInt();
    }
    for (int i = 0; i < n; i++) {
      heroes[i] = scan.nextInt();
    }
    scan.close();

    System.out.println(answer(mons, heroes));
  }
} import java.util.Scanner; Scanner java.util public class Main {

  private static long answer(long[] mons, long[] heroes) {
    long remain = mons[0];
    long sum = 0;
    for (int i = 0; i < heroes.length; i++) {
      long killed = Math.min(heroes[i], remain);
      long killed2 = Math.min(heroes[i] - killed, mons[i + 1]);
      remain = mons[i + 1] - killed2;
      sum += killed + killed2;
    }

    return sum;
  }

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    long[] mons = new long[n+1];
    long[] heroes = new long[n];
    for (int i = 0; i < n + 1; i++) {
      mons[i] = scan.nextInt();
    }
    for (int i = 0; i < n; i++) {
      heroes[i] = scan.nextInt();
    }
    scan.close();

    System.out.println(answer(mons, heroes));
  }
} Main private static long answer(long[] mons, long[] heroes) {
    long remain = mons[0];
    long sum = 0;
    for (int i = 0; i < heroes.length; i++) {
      long killed = Math.min(heroes[i], remain);
      long killed2 = Math.min(heroes[i] - killed, mons[i + 1]);
      remain = mons[i + 1] - killed2;
      sum += killed + killed2;
    }

    return sum;
  } answer {
    long remain = mons[0];
    long sum = 0;
    for (int i = 0; i < heroes.length; i++) {
      long killed = Math.min(heroes[i], remain);
      long killed2 = Math.min(heroes[i] - killed, mons[i + 1]);
      remain = mons[i + 1] - killed2;
      sum += killed + killed2;
    }

    return sum;
  } long remain = mons[0]; remain mons[0] mons 0 long sum = 0; sum 0 for (int i = 0; i < heroes.length; i++) {
      long killed = Math.min(heroes[i], remain);
      long killed2 = Math.min(heroes[i] - killed, mons[i + 1]);
      remain = mons[i + 1] - killed2;
      sum += killed + killed2;
    } int i = 0; int i = 0; i 0 i < heroes.length i heroes.length heroes heroes.length i++ i++ i {
      long killed = Math.min(heroes[i], remain);
      long killed2 = Math.min(heroes[i] - killed, mons[i + 1]);
      remain = mons[i + 1] - killed2;
      sum += killed + killed2;
    } {
      long killed = Math.min(heroes[i], remain);
      long killed2 = Math.min(heroes[i] - killed, mons[i + 1]);
      remain = mons[i + 1] - killed2;
      sum += killed + killed2;
    } long killed = Math.min(heroes[i], remain); killed Math.min(heroes[i], remain) Math.min Math heroes[i] heroes i remain long killed2 = Math.min(heroes[i] - killed, mons[i + 1]); killed2 Math.min(heroes[i] - killed, mons[i + 1]) Math.min Math heroes[i] - killed heroes[i] heroes i killed mons[i + 1] mons i + 1 i 1 remain = mons[i + 1] - killed2 remain mons[i + 1] - killed2 mons[i + 1] mons i + 1 i 1 killed2 sum += killed + killed2 sum killed + killed2 killed killed2 return sum; sum long[] mons mons long[] heroes heroes public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    long[] mons = new long[n+1];
    long[] heroes = new long[n];
    for (int i = 0; i < n + 1; i++) {
      mons[i] = scan.nextInt();
    }
    for (int i = 0; i < n; i++) {
      heroes[i] = scan.nextInt();
    }
    scan.close();

    System.out.println(answer(mons, heroes));
  } main {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    long[] mons = new long[n+1];
    long[] heroes = new long[n];
    for (int i = 0; i < n + 1; i++) {
      mons[i] = scan.nextInt();
    }
    for (int i = 0; i < n; i++) {
      heroes[i] = scan.nextInt();
    }
    scan.close();

    System.out.println(answer(mons, heroes));
  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan long[] mons = new long[n+1]; mons new long[n+1] n+1 n 1 long[] heroes = new long[n]; heroes new long[n] n for (int i = 0; i < n + 1; i++) {
      mons[i] = scan.nextInt();
    } int i = 0; int i = 0; i 0 i < n + 1 i n + 1 n 1 i++ i++ i {
      mons[i] = scan.nextInt();
    } {
      mons[i] = scan.nextInt();
    } mons[i] = scan.nextInt() mons[i] mons i scan.nextInt() scan.nextInt scan for (int i = 0; i < n; i++) {
      heroes[i] = scan.nextInt();
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      heroes[i] = scan.nextInt();
    } {
      heroes[i] = scan.nextInt();
    } heroes[i] = scan.nextInt() heroes[i] heroes i scan.nextInt() scan.nextInt scan scan.close() scan.close scan System.out.println(answer(mons, heroes)) System.out.println System.out System System.out answer(mons, heroes) answer mons heroes String[] args args public class Main {

  private static long answer(long[] mons, long[] heroes) {
    long remain = mons[0];
    long sum = 0;
    for (int i = 0; i < heroes.length; i++) {
      long killed = Math.min(heroes[i], remain);
      long killed2 = Math.min(heroes[i] - killed, mons[i + 1]);
      remain = mons[i + 1] - killed2;
      sum += killed + killed2;
    }

    return sum;
  }

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    long[] mons = new long[n+1];
    long[] heroes = new long[n];
    for (int i = 0; i < n + 1; i++) {
      mons[i] = scan.nextInt();
    }
    for (int i = 0; i < n; i++) {
      heroes[i] = scan.nextInt();
    }
    scan.close();

    System.out.println(answer(mons, heroes));
  }
} public class Main {

  private static long answer(long[] mons, long[] heroes) {
    long remain = mons[0];
    long sum = 0;
    for (int i = 0; i < heroes.length; i++) {
      long killed = Math.min(heroes[i], remain);
      long killed2 = Math.min(heroes[i] - killed, mons[i + 1]);
      remain = mons[i + 1] - killed2;
      sum += killed + killed2;
    }

    return sum;
  }

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    long[] mons = new long[n+1];
    long[] heroes = new long[n];
    for (int i = 0; i < n + 1; i++) {
      mons[i] = scan.nextInt();
    }
    for (int i = 0; i < n; i++) {
      heroes[i] = scan.nextInt();
    }
    scan.close();

    System.out.println(answer(mons, heroes));
  }
} Main
import java.util.Scanner;

/**
 * https://atcoder.jp/contests/abc135/tasks/abc135_c
 */
public class Main {

  private static long answer(long[] mons, long[] heroes) {
    long remain = mons[0];
    long sum = 0;
    for (int i = 0; i < heroes.length; i++) {
      long killed = Math.min(heroes[i], remain);
      long killed2 = Math.min(heroes[i] - killed, mons[i + 1]);
      remain = mons[i + 1] - killed2;
      sum += killed + killed2;
    }

    return sum;
  }

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    long[] mons = new long[n+1];
    long[] heroes = new long[n];
    for (int i = 0; i < n + 1; i++) {
      mons[i] = scan.nextInt();
    }
    for (int i = 0; i < n; i++) {
      heroes[i] = scan.nextInt();
    }
    scan.close();

    System.out.println(answer(mons, heroes));
  }
}
