import java.util.*;
import java.util.stream.*;

public class Main {
  public static void main(String[] args) throws Exception {
    Scanner in = new Scanner(System.in);
    int N = in.nextInt();
    long[] A = new long[N + 1];
    long[] B = new long[N];
    for (int i = 0; i < N + 1; i++) {
      A[i] = in.nextLong();
    }
    for (int i = 0; i < N; i++) {
      B[i] = in.nextLong();
    }
    long ans = 0;
    for (int i = 0; i < N; i++) {
      ans += Math.min(A[i], B[i]);
      B[i] -= Math.min(A[i], B[i]);
      ans += Math.min(A[i + 1], B[i]);
      A[i + 1] -= Math.min(A[i + 1], B[i]);
    }
    System.out.println(ans);
  }
} import java.util.*; util.* java import java.util.stream.*; stream.* java.util public class Main {
  public static void main(String[] args) throws Exception {
    Scanner in = new Scanner(System.in);
    int N = in.nextInt();
    long[] A = new long[N + 1];
    long[] B = new long[N];
    for (int i = 0; i < N + 1; i++) {
      A[i] = in.nextLong();
    }
    for (int i = 0; i < N; i++) {
      B[i] = in.nextLong();
    }
    long ans = 0;
    for (int i = 0; i < N; i++) {
      ans += Math.min(A[i], B[i]);
      B[i] -= Math.min(A[i], B[i]);
      ans += Math.min(A[i + 1], B[i]);
      A[i + 1] -= Math.min(A[i + 1], B[i]);
    }
    System.out.println(ans);
  }
} Main public static void main(String[] args) throws Exception {
    Scanner in = new Scanner(System.in);
    int N = in.nextInt();
    long[] A = new long[N + 1];
    long[] B = new long[N];
    for (int i = 0; i < N + 1; i++) {
      A[i] = in.nextLong();
    }
    for (int i = 0; i < N; i++) {
      B[i] = in.nextLong();
    }
    long ans = 0;
    for (int i = 0; i < N; i++) {
      ans += Math.min(A[i], B[i]);
      B[i] -= Math.min(A[i], B[i]);
      ans += Math.min(A[i + 1], B[i]);
      A[i + 1] -= Math.min(A[i + 1], B[i]);
    }
    System.out.println(ans);
  } main {
    Scanner in = new Scanner(System.in);
    int N = in.nextInt();
    long[] A = new long[N + 1];
    long[] B = new long[N];
    for (int i = 0; i < N + 1; i++) {
      A[i] = in.nextLong();
    }
    for (int i = 0; i < N; i++) {
      B[i] = in.nextLong();
    }
    long ans = 0;
    for (int i = 0; i < N; i++) {
      ans += Math.min(A[i], B[i]);
      B[i] -= Math.min(A[i], B[i]);
      ans += Math.min(A[i + 1], B[i]);
      A[i + 1] -= Math.min(A[i + 1], B[i]);
    }
    System.out.println(ans);
  } Scanner in = new Scanner(System.in); in new Scanner(System.in) int N = in.nextInt(); N in.nextInt() in.nextInt in 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 + 1; i++) {
      A[i] = in.nextLong();
    } int i = 0; int i = 0; i 0 i < N + 1 i N + 1 N 1 i++ i++ i {
      A[i] = in.nextLong();
    } {
      A[i] = in.nextLong();
    } A[i] = in.nextLong() A[i] A i in.nextLong() in.nextLong in for (int i = 0; i < N; i++) {
      B[i] = in.nextLong();
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      B[i] = in.nextLong();
    } {
      B[i] = in.nextLong();
    } B[i] = in.nextLong() B[i] B i in.nextLong() in.nextLong in long ans = 0; ans 0 for (int i = 0; i < N; i++) {
      ans += Math.min(A[i], B[i]);
      B[i] -= Math.min(A[i], B[i]);
      ans += Math.min(A[i + 1], B[i]);
      A[i + 1] -= Math.min(A[i + 1], B[i]);
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      ans += Math.min(A[i], B[i]);
      B[i] -= Math.min(A[i], B[i]);
      ans += Math.min(A[i + 1], B[i]);
      A[i + 1] -= Math.min(A[i + 1], B[i]);
    } {
      ans += Math.min(A[i], B[i]);
      B[i] -= Math.min(A[i], B[i]);
      ans += Math.min(A[i + 1], B[i]);
      A[i + 1] -= Math.min(A[i + 1], B[i]);
    } ans += Math.min(A[i], B[i]) ans Math.min(A[i], B[i]) Math.min Math A[i] A i B[i] B i B[i] -= Math.min(A[i], B[i]) B[i] B i Math.min(A[i], B[i]) Math.min Math A[i] A i B[i] B i ans += Math.min(A[i + 1], B[i]) ans Math.min(A[i + 1], B[i]) Math.min Math A[i + 1] A i + 1 i 1 B[i] B i A[i + 1] -= Math.min(A[i + 1], B[i]) A[i + 1] A i + 1 i 1 Math.min(A[i + 1], B[i]) Math.min Math A[i + 1] A i + 1 i 1 B[i] B i System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
  public static void main(String[] args) throws Exception {
    Scanner in = new Scanner(System.in);
    int N = in.nextInt();
    long[] A = new long[N + 1];
    long[] B = new long[N];
    for (int i = 0; i < N + 1; i++) {
      A[i] = in.nextLong();
    }
    for (int i = 0; i < N; i++) {
      B[i] = in.nextLong();
    }
    long ans = 0;
    for (int i = 0; i < N; i++) {
      ans += Math.min(A[i], B[i]);
      B[i] -= Math.min(A[i], B[i]);
      ans += Math.min(A[i + 1], B[i]);
      A[i + 1] -= Math.min(A[i + 1], B[i]);
    }
    System.out.println(ans);
  }
} public class Main {
  public static void main(String[] args) throws Exception {
    Scanner in = new Scanner(System.in);
    int N = in.nextInt();
    long[] A = new long[N + 1];
    long[] B = new long[N];
    for (int i = 0; i < N + 1; i++) {
      A[i] = in.nextLong();
    }
    for (int i = 0; i < N; i++) {
      B[i] = in.nextLong();
    }
    long ans = 0;
    for (int i = 0; i < N; i++) {
      ans += Math.min(A[i], B[i]);
      B[i] -= Math.min(A[i], B[i]);
      ans += Math.min(A[i + 1], B[i]);
      A[i + 1] -= Math.min(A[i + 1], B[i]);
    }
    System.out.println(ans);
  }
} Main
import java.util.*;
import java.util.stream.*;

public class Main {
  public static void main(String[] args) throws Exception {
    Scanner in = new Scanner(System.in);
    int N = in.nextInt();
    long[] A = new long[N + 1];
    long[] B = new long[N];
    for (int i = 0; i < N + 1; i++) {
      A[i] = in.nextLong();
    }
    for (int i = 0; i < N; i++) {
      B[i] = in.nextLong();
    }
    long ans = 0;
    for (int i = 0; i < N; i++) {
      ans += Math.min(A[i], B[i]);
      B[i] -= Math.min(A[i], B[i]);
      ans += Math.min(A[i + 1], B[i]);
      A[i + 1] -= Math.min(A[i + 1], B[i]);
    }
    System.out.println(ans);
  }
}