import java.util.*;
public class Main {
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = Integer.parseInt(sc.next());
	long[] listA = new long[n+1];
	long[] listB = new long[n];
	for(int i =0; i<n+1; i++) {
			listA[i] = Integer.parseInt(sc.next());
	}
	for(int i =0; i<n; i++) {
			listB[i] = Integer.parseInt(sc.next());
	}

	long sum =0;
	long power = 0;
	long least = listA[n];
	for(int i=n; i>=1; i--) {
		if(least<listB[i-1]) {
			sum = sum + least;
			power = listB[i-1] - least;
		}else {
			sum = sum + listB[i-1];
			power = 0;
		}

		least = listA[i-1] - power;
		if(least<0) {
			least = 0;
			sum = sum + listA[i-1];
		}else {
			sum = sum + power;
		}
		
	}
	

	System.out.println(sum);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = Integer.parseInt(sc.next());
	long[] listA = new long[n+1];
	long[] listB = new long[n];
	for(int i =0; i<n+1; i++) {
			listA[i] = Integer.parseInt(sc.next());
	}
	for(int i =0; i<n; i++) {
			listB[i] = Integer.parseInt(sc.next());
	}

	long sum =0;
	long power = 0;
	long least = listA[n];
	for(int i=n; i>=1; i--) {
		if(least<listB[i-1]) {
			sum = sum + least;
			power = listB[i-1] - least;
		}else {
			sum = sum + listB[i-1];
			power = 0;
		}

		least = listA[i-1] - power;
		if(least<0) {
			least = 0;
			sum = sum + listA[i-1];
		}else {
			sum = sum + power;
		}
		
	}
	

	System.out.println(sum);
	}
} Main public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = Integer.parseInt(sc.next());
	long[] listA = new long[n+1];
	long[] listB = new long[n];
	for(int i =0; i<n+1; i++) {
			listA[i] = Integer.parseInt(sc.next());
	}
	for(int i =0; i<n; i++) {
			listB[i] = Integer.parseInt(sc.next());
	}

	long sum =0;
	long power = 0;
	long least = listA[n];
	for(int i=n; i>=1; i--) {
		if(least<listB[i-1]) {
			sum = sum + least;
			power = listB[i-1] - least;
		}else {
			sum = sum + listB[i-1];
			power = 0;
		}

		least = listA[i-1] - power;
		if(least<0) {
			least = 0;
			sum = sum + listA[i-1];
		}else {
			sum = sum + power;
		}
		
	}
	

	System.out.println(sum);
	} main {
	Scanner sc = new Scanner(System.in);
	int n = Integer.parseInt(sc.next());
	long[] listA = new long[n+1];
	long[] listB = new long[n];
	for(int i =0; i<n+1; i++) {
			listA[i] = Integer.parseInt(sc.next());
	}
	for(int i =0; i<n; i++) {
			listB[i] = Integer.parseInt(sc.next());
	}

	long sum =0;
	long power = 0;
	long least = listA[n];
	for(int i=n; i>=1; i--) {
		if(least<listB[i-1]) {
			sum = sum + least;
			power = listB[i-1] - least;
		}else {
			sum = sum + listB[i-1];
			power = 0;
		}

		least = listA[i-1] - power;
		if(least<0) {
			least = 0;
			sum = sum + listA[i-1];
		}else {
			sum = sum + power;
		}
		
	}
	

	System.out.println(sum);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc long[] listA = new long[n+1]; listA new long[n+1] n+1 n 1 long[] listB = new long[n]; listB new long[n] n for(int i =0; i<n+1; i++) {
			listA[i] = Integer.parseInt(sc.next());
	} int i =0; int i =0; i 0 i<n+1 i n+1 n 1 i++ i++ i {
			listA[i] = Integer.parseInt(sc.next());
	} {
			listA[i] = Integer.parseInt(sc.next());
	} listA[i] = Integer.parseInt(sc.next()) listA[i] listA i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc for(int i =0; i<n; i++) {
			listB[i] = Integer.parseInt(sc.next());
	} int i =0; int i =0; i 0 i<n i n i++ i++ i {
			listB[i] = Integer.parseInt(sc.next());
	} {
			listB[i] = Integer.parseInt(sc.next());
	} listB[i] = Integer.parseInt(sc.next()) listB[i] listB i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc long sum =0; sum 0 long power = 0; power 0 long least = listA[n]; least listA[n] listA n for(int i=n; i>=1; i--) {
		if(least<listB[i-1]) {
			sum = sum + least;
			power = listB[i-1] - least;
		}else {
			sum = sum + listB[i-1];
			power = 0;
		}

		least = listA[i-1] - power;
		if(least<0) {
			least = 0;
			sum = sum + listA[i-1];
		}else {
			sum = sum + power;
		}
		
	} int i=n; int i=n; i n i>=1 i 1 i-- i-- i {
		if(least<listB[i-1]) {
			sum = sum + least;
			power = listB[i-1] - least;
		}else {
			sum = sum + listB[i-1];
			power = 0;
		}

		least = listA[i-1] - power;
		if(least<0) {
			least = 0;
			sum = sum + listA[i-1];
		}else {
			sum = sum + power;
		}
		
	} {
		if(least<listB[i-1]) {
			sum = sum + least;
			power = listB[i-1] - least;
		}else {
			sum = sum + listB[i-1];
			power = 0;
		}

		least = listA[i-1] - power;
		if(least<0) {
			least = 0;
			sum = sum + listA[i-1];
		}else {
			sum = sum + power;
		}
		
	} if(least<listB[i-1]) {
			sum = sum + least;
			power = listB[i-1] - least;
		}else {
			sum = sum + listB[i-1];
			power = 0;
		} least<listB[i-1] least listB[i-1] listB i-1 i 1 {
			sum = sum + least;
			power = listB[i-1] - least;
		} sum = sum + least sum sum + least sum least power = listB[i-1] - least power listB[i-1] - least listB[i-1] listB i-1 i 1 least {
			sum = sum + listB[i-1];
			power = 0;
		} sum = sum + listB[i-1] sum sum + listB[i-1] sum listB[i-1] listB i-1 i 1 power = 0 power 0 least = listA[i-1] - power least listA[i-1] - power listA[i-1] listA i-1 i 1 power if(least<0) {
			least = 0;
			sum = sum + listA[i-1];
		}else {
			sum = sum + power;
		} least<0 least 0 {
			least = 0;
			sum = sum + listA[i-1];
		} least = 0 least 0 sum = sum + listA[i-1] sum sum + listA[i-1] sum listA[i-1] listA i-1 i 1 {
			sum = sum + power;
		} sum = sum + power sum sum + power sum power 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 = Integer.parseInt(sc.next());
	long[] listA = new long[n+1];
	long[] listB = new long[n];
	for(int i =0; i<n+1; i++) {
			listA[i] = Integer.parseInt(sc.next());
	}
	for(int i =0; i<n; i++) {
			listB[i] = Integer.parseInt(sc.next());
	}

	long sum =0;
	long power = 0;
	long least = listA[n];
	for(int i=n; i>=1; i--) {
		if(least<listB[i-1]) {
			sum = sum + least;
			power = listB[i-1] - least;
		}else {
			sum = sum + listB[i-1];
			power = 0;
		}

		least = listA[i-1] - power;
		if(least<0) {
			least = 0;
			sum = sum + listA[i-1];
		}else {
			sum = sum + power;
		}
		
	}
	

	System.out.println(sum);
	}
} public class Main {
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = Integer.parseInt(sc.next());
	long[] listA = new long[n+1];
	long[] listB = new long[n];
	for(int i =0; i<n+1; i++) {
			listA[i] = Integer.parseInt(sc.next());
	}
	for(int i =0; i<n; i++) {
			listB[i] = Integer.parseInt(sc.next());
	}

	long sum =0;
	long power = 0;
	long least = listA[n];
	for(int i=n; i>=1; i--) {
		if(least<listB[i-1]) {
			sum = sum + least;
			power = listB[i-1] - least;
		}else {
			sum = sum + listB[i-1];
			power = 0;
		}

		least = listA[i-1] - power;
		if(least<0) {
			least = 0;
			sum = sum + listA[i-1];
		}else {
			sum = sum + power;
		}
		
	}
	

	System.out.println(sum);
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = Integer.parseInt(sc.next());
	long[] listA = new long[n+1];
	long[] listB = new long[n];
	for(int i =0; i<n+1; i++) {
			listA[i] = Integer.parseInt(sc.next());
	}
	for(int i =0; i<n; i++) {
			listB[i] = Integer.parseInt(sc.next());
	}

	long sum =0;
	long power = 0;
	long least = listA[n];
	for(int i=n; i>=1; i--) {
		if(least<listB[i-1]) {
			sum = sum + least;
			power = listB[i-1] - least;
		}else {
			sum = sum + listB[i-1];
			power = 0;
		}

		least = listA[i-1] - power;
		if(least<0) {
			least = 0;
			sum = sum + listA[i-1];
		}else {
			sum = sum + power;
		}
		
	}
	

	System.out.println(sum);
	}
}