import java.util.*;

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

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