import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    long[] arrayA = new long[N + 1];
    long result = 0;
    for (int i = 0; i < N + 1; i++) {
      arrayA[i] = scan.nextLong();
    }
    for (int i = 0; i < N; i++) {
      long tmp = scan.nextLong();

      if (tmp >= arrayA[i]) {
        result += arrayA[i];
        tmp -= arrayA[i];
      } else {
        result += tmp;
        continue;
      }
      if (tmp >= arrayA[i + 1]) {
        result += arrayA[i + 1];
        arrayA[i + 1] = 0;
      } else {
        result += tmp;
        arrayA[i + 1] -= tmp;
      }

    }

    System.out.println(result);
  }

} import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    long[] arrayA = new long[N + 1];
    long result = 0;
    for (int i = 0; i < N + 1; i++) {
      arrayA[i] = scan.nextLong();
    }
    for (int i = 0; i < N; i++) {
      long tmp = scan.nextLong();

      if (tmp >= arrayA[i]) {
        result += arrayA[i];
        tmp -= arrayA[i];
      } else {
        result += tmp;
        continue;
      }
      if (tmp >= arrayA[i + 1]) {
        result += arrayA[i + 1];
        arrayA[i + 1] = 0;
      } else {
        result += tmp;
        arrayA[i + 1] -= tmp;
      }

    }

    System.out.println(result);
  }

} Main public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    long[] arrayA = new long[N + 1];
    long result = 0;
    for (int i = 0; i < N + 1; i++) {
      arrayA[i] = scan.nextLong();
    }
    for (int i = 0; i < N; i++) {
      long tmp = scan.nextLong();

      if (tmp >= arrayA[i]) {
        result += arrayA[i];
        tmp -= arrayA[i];
      } else {
        result += tmp;
        continue;
      }
      if (tmp >= arrayA[i + 1]) {
        result += arrayA[i + 1];
        arrayA[i + 1] = 0;
      } else {
        result += tmp;
        arrayA[i + 1] -= tmp;
      }

    }

    System.out.println(result);
  } main {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    long[] arrayA = new long[N + 1];
    long result = 0;
    for (int i = 0; i < N + 1; i++) {
      arrayA[i] = scan.nextLong();
    }
    for (int i = 0; i < N; i++) {
      long tmp = scan.nextLong();

      if (tmp >= arrayA[i]) {
        result += arrayA[i];
        tmp -= arrayA[i];
      } else {
        result += tmp;
        continue;
      }
      if (tmp >= arrayA[i + 1]) {
        result += arrayA[i + 1];
        arrayA[i + 1] = 0;
      } else {
        result += tmp;
        arrayA[i + 1] -= tmp;
      }

    }

    System.out.println(result);
  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan long[] arrayA = new long[N + 1]; arrayA new long[N + 1] N + 1 N 1 long result = 0; result 0 for (int i = 0; i < N + 1; i++) {
      arrayA[i] = scan.nextLong();
    } int i = 0; int i = 0; i 0 i < N + 1 i N + 1 N 1 i++ i++ i {
      arrayA[i] = scan.nextLong();
    } {
      arrayA[i] = scan.nextLong();
    } arrayA[i] = scan.nextLong() arrayA[i] arrayA i scan.nextLong() scan.nextLong scan for (int i = 0; i < N; i++) {
      long tmp = scan.nextLong();

      if (tmp >= arrayA[i]) {
        result += arrayA[i];
        tmp -= arrayA[i];
      } else {
        result += tmp;
        continue;
      }
      if (tmp >= arrayA[i + 1]) {
        result += arrayA[i + 1];
        arrayA[i + 1] = 0;
      } else {
        result += tmp;
        arrayA[i + 1] -= tmp;
      }

    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      long tmp = scan.nextLong();

      if (tmp >= arrayA[i]) {
        result += arrayA[i];
        tmp -= arrayA[i];
      } else {
        result += tmp;
        continue;
      }
      if (tmp >= arrayA[i + 1]) {
        result += arrayA[i + 1];
        arrayA[i + 1] = 0;
      } else {
        result += tmp;
        arrayA[i + 1] -= tmp;
      }

    } {
      long tmp = scan.nextLong();

      if (tmp >= arrayA[i]) {
        result += arrayA[i];
        tmp -= arrayA[i];
      } else {
        result += tmp;
        continue;
      }
      if (tmp >= arrayA[i + 1]) {
        result += arrayA[i + 1];
        arrayA[i + 1] = 0;
      } else {
        result += tmp;
        arrayA[i + 1] -= tmp;
      }

    } long tmp = scan.nextLong(); tmp scan.nextLong() scan.nextLong scan if (tmp >= arrayA[i]) {
        result += arrayA[i];
        tmp -= arrayA[i];
      } else {
        result += tmp;
        continue;
      } tmp >= arrayA[i] tmp arrayA[i] arrayA i {
        result += arrayA[i];
        tmp -= arrayA[i];
      } result += arrayA[i] result arrayA[i] arrayA i tmp -= arrayA[i] tmp arrayA[i] arrayA i {
        result += tmp;
        continue;
      } result += tmp result tmp continue; if (tmp >= arrayA[i + 1]) {
        result += arrayA[i + 1];
        arrayA[i + 1] = 0;
      } else {
        result += tmp;
        arrayA[i + 1] -= tmp;
      } tmp >= arrayA[i + 1] tmp arrayA[i + 1] arrayA i + 1 i 1 {
        result += arrayA[i + 1];
        arrayA[i + 1] = 0;
      } result += arrayA[i + 1] result arrayA[i + 1] arrayA i + 1 i 1 arrayA[i + 1] = 0 arrayA[i + 1] arrayA i + 1 i 1 0 {
        result += tmp;
        arrayA[i + 1] -= tmp;
      } result += tmp result tmp arrayA[i + 1] -= tmp arrayA[i + 1] arrayA i + 1 i 1 tmp System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    long[] arrayA = new long[N + 1];
    long result = 0;
    for (int i = 0; i < N + 1; i++) {
      arrayA[i] = scan.nextLong();
    }
    for (int i = 0; i < N; i++) {
      long tmp = scan.nextLong();

      if (tmp >= arrayA[i]) {
        result += arrayA[i];
        tmp -= arrayA[i];
      } else {
        result += tmp;
        continue;
      }
      if (tmp >= arrayA[i + 1]) {
        result += arrayA[i + 1];
        arrayA[i + 1] = 0;
      } else {
        result += tmp;
        arrayA[i + 1] -= tmp;
      }

    }

    System.out.println(result);
  }

} public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    long[] arrayA = new long[N + 1];
    long result = 0;
    for (int i = 0; i < N + 1; i++) {
      arrayA[i] = scan.nextLong();
    }
    for (int i = 0; i < N; i++) {
      long tmp = scan.nextLong();

      if (tmp >= arrayA[i]) {
        result += arrayA[i];
        tmp -= arrayA[i];
      } else {
        result += tmp;
        continue;
      }
      if (tmp >= arrayA[i + 1]) {
        result += arrayA[i + 1];
        arrayA[i + 1] = 0;
      } else {
        result += tmp;
        arrayA[i + 1] -= tmp;
      }

    }

    System.out.println(result);
  }

} Main
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    long[] arrayA = new long[N + 1];
    long result = 0;
    for (int i = 0; i < N + 1; i++) {
      arrayA[i] = scan.nextLong();
    }
    for (int i = 0; i < N; i++) {
      long tmp = scan.nextLong();

      if (tmp >= arrayA[i]) {
        result += arrayA[i];
        tmp -= arrayA[i];
      } else {
        result += tmp;
        continue;
      }
      if (tmp >= arrayA[i + 1]) {
        result += arrayA[i + 1];
        arrayA[i + 1] = 0;
      } else {
        result += tmp;
        arrayA[i + 1] -= tmp;
      }

    }

    System.out.println(result);
  }

}
