import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] bi = new int[N+1], max = new int[N];
		for(int i = 0; i <= N; i++) bi[i] = sc.nextInt();
		for(int j = 0; j < N; j++) max[j] = sc.nextInt();

		long sum = 0;
		for(int i = 0; i < N; i++) {
			long x = Math.min(bi[i], max[i]);
			sum += x;
			x = Math.min(max[i]-x, bi[i+1]);
			bi[i+1] -= x;
			sum += x;
		}
		System.out.println(sum);
	}
} 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();
		int[] bi = new int[N+1], max = new int[N];
		for(int i = 0; i <= N; i++) bi[i] = sc.nextInt();
		for(int j = 0; j < N; j++) max[j] = sc.nextInt();

		long sum = 0;
		for(int i = 0; i < N; i++) {
			long x = Math.min(bi[i], max[i]);
			sum += x;
			x = Math.min(max[i]-x, bi[i+1]);
			bi[i+1] -= x;
			sum += x;
		}
		System.out.println(sum);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] bi = new int[N+1], max = new int[N];
		for(int i = 0; i <= N; i++) bi[i] = sc.nextInt();
		for(int j = 0; j < N; j++) max[j] = sc.nextInt();

		long sum = 0;
		for(int i = 0; i < N; i++) {
			long x = Math.min(bi[i], max[i]);
			sum += x;
			x = Math.min(max[i]-x, bi[i+1]);
			bi[i+1] -= x;
			sum += x;
		}
		System.out.println(sum);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] bi = new int[N+1], max = new int[N];
		for(int i = 0; i <= N; i++) bi[i] = sc.nextInt();
		for(int j = 0; j < N; j++) max[j] = sc.nextInt();

		long sum = 0;
		for(int i = 0; i < N; i++) {
			long x = Math.min(bi[i], max[i]);
			sum += x;
			x = Math.min(max[i]-x, bi[i+1]);
			bi[i+1] -= x;
			sum += x;
		}
		System.out.println(sum);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] bi = new int[N+1] bi new int[N+1] N+1 N 1 max = new int[N]; max new int[N] N for(int i = 0; i <= N; i++) bi[i] = sc.nextInt(); int i = 0; int i = 0; i 0 i <= N i N i++ i++ i bi[i] = sc.nextInt(); bi[i] = sc.nextInt() bi[i] bi i sc.nextInt() sc.nextInt sc for(int j = 0; j < N; j++) max[j] = sc.nextInt(); int j = 0; int j = 0; j 0 j < N j N j++ j++ j max[j] = sc.nextInt(); max[j] = sc.nextInt() max[j] max j sc.nextInt() sc.nextInt sc long sum = 0; sum 0 for(int i = 0; i < N; i++) {
			long x = Math.min(bi[i], max[i]);
			sum += x;
			x = Math.min(max[i]-x, bi[i+1]);
			bi[i+1] -= x;
			sum += x;
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			long x = Math.min(bi[i], max[i]);
			sum += x;
			x = Math.min(max[i]-x, bi[i+1]);
			bi[i+1] -= x;
			sum += x;
		} {
			long x = Math.min(bi[i], max[i]);
			sum += x;
			x = Math.min(max[i]-x, bi[i+1]);
			bi[i+1] -= x;
			sum += x;
		} long x = Math.min(bi[i], max[i]); x Math.min(bi[i], max[i]) Math.min Math bi[i] bi i max[i] max i sum += x sum x x = Math.min(max[i]-x, bi[i+1]) x Math.min(max[i]-x, bi[i+1]) Math.min Math max[i]-x max[i] max i x bi[i+1] bi i+1 i 1 bi[i+1] -= x bi[i+1] bi i+1 i 1 x sum += x sum x System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] bi = new int[N+1], max = new int[N];
		for(int i = 0; i <= N; i++) bi[i] = sc.nextInt();
		for(int j = 0; j < N; j++) max[j] = sc.nextInt();

		long sum = 0;
		for(int i = 0; i < N; i++) {
			long x = Math.min(bi[i], max[i]);
			sum += x;
			x = Math.min(max[i]-x, bi[i+1]);
			bi[i+1] -= x;
			sum += x;
		}
		System.out.println(sum);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] bi = new int[N+1], max = new int[N];
		for(int i = 0; i <= N; i++) bi[i] = sc.nextInt();
		for(int j = 0; j < N; j++) max[j] = sc.nextInt();

		long sum = 0;
		for(int i = 0; i < N; i++) {
			long x = Math.min(bi[i], max[i]);
			sum += x;
			x = Math.min(max[i]-x, bi[i+1]);
			bi[i+1] -= x;
			sum += x;
		}
		System.out.println(sum);
	}
} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] bi = new int[N+1], max = new int[N];
		for(int i = 0; i <= N; i++) bi[i] = sc.nextInt();
		for(int j = 0; j < N; j++) max[j] = sc.nextInt();

		long sum = 0;
		for(int i = 0; i < N; i++) {
			long x = Math.min(bi[i], max[i]);
			sum += x;
			x = Math.min(max[i]-x, bi[i+1]);
			bi[i+1] -= x;
			sum += x;
		}
		System.out.println(sum);
	}
}