import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		long resultSum =0;
		List<Long> aList = new ArrayList<>(n+1);
		List<Long> bList = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			long a = Long.parseLong(sc.next());
			aList.add(a);
		}
		aList.add(Long.parseLong(sc.next()));

		for (int i = 0; i < n; i++) {
			long b = Long.parseLong(sc.next());
			bList.add(b);
			resultSum += b;
		}


		// System.out.println("aList " + aList);

		// System.out.println("bList " + bList);

		long prevAmari  = aList.get(n);
		for (int i = n-1; i >= 0 ; i--) {
			// System.out.println("i " + i);

			long b = bList.get(i);
			long ai = aList.get(i);
			long bPower = b;
			if(prevAmari>=0){
				if(bPower>=prevAmari){
					bPower = bPower - prevAmari;
				}else{
					bPower = 0;
				}
			}

			if(bPower >= ai){
				prevAmari =0;
				resultSum -= bPower-ai;
			}else{
				prevAmari = ai - bPower;
			}
			// System.out.println("b " + b);
			// System.out.println("ai " + ai);

			// System.out.println("prevAmari " + prevAmari);
			// System.out.println("bPower " + bPower);
			// System.out.println("resultSum " + resultSum);
		}
		System.out.println(resultSum);


	}

} import java.util.*; util.* java import java.math.*; math.* java import java.lang.*; lang.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		long resultSum =0;
		List<Long> aList = new ArrayList<>(n+1);
		List<Long> bList = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			long a = Long.parseLong(sc.next());
			aList.add(a);
		}
		aList.add(Long.parseLong(sc.next()));

		for (int i = 0; i < n; i++) {
			long b = Long.parseLong(sc.next());
			bList.add(b);
			resultSum += b;
		}


		// System.out.println("aList " + aList);

		// System.out.println("bList " + bList);

		long prevAmari  = aList.get(n);
		for (int i = n-1; i >= 0 ; i--) {
			// System.out.println("i " + i);

			long b = bList.get(i);
			long ai = aList.get(i);
			long bPower = b;
			if(prevAmari>=0){
				if(bPower>=prevAmari){
					bPower = bPower - prevAmari;
				}else{
					bPower = 0;
				}
			}

			if(bPower >= ai){
				prevAmari =0;
				resultSum -= bPower-ai;
			}else{
				prevAmari = ai - bPower;
			}
			// System.out.println("b " + b);
			// System.out.println("ai " + ai);

			// System.out.println("prevAmari " + prevAmari);
			// System.out.println("bPower " + bPower);
			// System.out.println("resultSum " + resultSum);
		}
		System.out.println(resultSum);


	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		long resultSum =0;
		List<Long> aList = new ArrayList<>(n+1);
		List<Long> bList = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			long a = Long.parseLong(sc.next());
			aList.add(a);
		}
		aList.add(Long.parseLong(sc.next()));

		for (int i = 0; i < n; i++) {
			long b = Long.parseLong(sc.next());
			bList.add(b);
			resultSum += b;
		}


		// System.out.println("aList " + aList);

		// System.out.println("bList " + bList);

		long prevAmari  = aList.get(n);
		for (int i = n-1; i >= 0 ; i--) {
			// System.out.println("i " + i);

			long b = bList.get(i);
			long ai = aList.get(i);
			long bPower = b;
			if(prevAmari>=0){
				if(bPower>=prevAmari){
					bPower = bPower - prevAmari;
				}else{
					bPower = 0;
				}
			}

			if(bPower >= ai){
				prevAmari =0;
				resultSum -= bPower-ai;
			}else{
				prevAmari = ai - bPower;
			}
			// System.out.println("b " + b);
			// System.out.println("ai " + ai);

			// System.out.println("prevAmari " + prevAmari);
			// System.out.println("bPower " + bPower);
			// System.out.println("resultSum " + resultSum);
		}
		System.out.println(resultSum);


	} main {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		long resultSum =0;
		List<Long> aList = new ArrayList<>(n+1);
		List<Long> bList = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			long a = Long.parseLong(sc.next());
			aList.add(a);
		}
		aList.add(Long.parseLong(sc.next()));

		for (int i = 0; i < n; i++) {
			long b = Long.parseLong(sc.next());
			bList.add(b);
			resultSum += b;
		}


		// System.out.println("aList " + aList);

		// System.out.println("bList " + bList);

		long prevAmari  = aList.get(n);
		for (int i = n-1; i >= 0 ; i--) {
			// System.out.println("i " + i);

			long b = bList.get(i);
			long ai = aList.get(i);
			long bPower = b;
			if(prevAmari>=0){
				if(bPower>=prevAmari){
					bPower = bPower - prevAmari;
				}else{
					bPower = 0;
				}
			}

			if(bPower >= ai){
				prevAmari =0;
				resultSum -= bPower-ai;
			}else{
				prevAmari = ai - bPower;
			}
			// System.out.println("b " + b);
			// System.out.println("ai " + ai);

			// System.out.println("prevAmari " + prevAmari);
			// System.out.println("bPower " + bPower);
			// System.out.println("resultSum " + resultSum);
		}
		System.out.println(resultSum);


	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc long resultSum =0; resultSum 0 List<Long> aList = new ArrayList<>(n+1); aList new ArrayList<>(n+1) List<Long> bList = new ArrayList<>(n); bList new ArrayList<>(n) for (int i = 0; i < n; i++) {
			long a = Long.parseLong(sc.next());
			aList.add(a);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			long a = Long.parseLong(sc.next());
			aList.add(a);
		} {
			long a = Long.parseLong(sc.next());
			aList.add(a);
		} long a = Long.parseLong(sc.next()); a Long.parseLong(sc.next()) Long.parseLong Long sc.next() sc.next sc aList.add(a) aList.add aList a aList.add(Long.parseLong(sc.next())) aList.add aList Long.parseLong(sc.next()) Long.parseLong Long sc.next() sc.next sc for (int i = 0; i < n; i++) {
			long b = Long.parseLong(sc.next());
			bList.add(b);
			resultSum += b;
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			long b = Long.parseLong(sc.next());
			bList.add(b);
			resultSum += b;
		} {
			long b = Long.parseLong(sc.next());
			bList.add(b);
			resultSum += b;
		} long b = Long.parseLong(sc.next()); b Long.parseLong(sc.next()) Long.parseLong Long sc.next() sc.next sc bList.add(b) bList.add bList b resultSum += b resultSum b long prevAmari  = aList.get(n); prevAmari aList.get(n) aList.get aList n for (int i = n-1; i >= 0 ; i--) {
			// System.out.println("i " + i);

			long b = bList.get(i);
			long ai = aList.get(i);
			long bPower = b;
			if(prevAmari>=0){
				if(bPower>=prevAmari){
					bPower = bPower - prevAmari;
				}else{
					bPower = 0;
				}
			}

			if(bPower >= ai){
				prevAmari =0;
				resultSum -= bPower-ai;
			}else{
				prevAmari = ai - bPower;
			}
			// System.out.println("b " + b);
			// System.out.println("ai " + ai);

			// System.out.println("prevAmari " + prevAmari);
			// System.out.println("bPower " + bPower);
			// System.out.println("resultSum " + resultSum);
		} int i = n-1; int i = n-1; i n-1 n 1 i >= 0 i 0 i-- i-- i {
			// System.out.println("i " + i);

			long b = bList.get(i);
			long ai = aList.get(i);
			long bPower = b;
			if(prevAmari>=0){
				if(bPower>=prevAmari){
					bPower = bPower - prevAmari;
				}else{
					bPower = 0;
				}
			}

			if(bPower >= ai){
				prevAmari =0;
				resultSum -= bPower-ai;
			}else{
				prevAmari = ai - bPower;
			}
			// System.out.println("b " + b);
			// System.out.println("ai " + ai);

			// System.out.println("prevAmari " + prevAmari);
			// System.out.println("bPower " + bPower);
			// System.out.println("resultSum " + resultSum);
		} {
			// System.out.println("i " + i);

			long b = bList.get(i);
			long ai = aList.get(i);
			long bPower = b;
			if(prevAmari>=0){
				if(bPower>=prevAmari){
					bPower = bPower - prevAmari;
				}else{
					bPower = 0;
				}
			}

			if(bPower >= ai){
				prevAmari =0;
				resultSum -= bPower-ai;
			}else{
				prevAmari = ai - bPower;
			}
			// System.out.println("b " + b);
			// System.out.println("ai " + ai);

			// System.out.println("prevAmari " + prevAmari);
			// System.out.println("bPower " + bPower);
			// System.out.println("resultSum " + resultSum);
		} long b = bList.get(i); b bList.get(i) bList.get bList i long ai = aList.get(i); ai aList.get(i) aList.get aList i long bPower = b; bPower b if(prevAmari>=0){
				if(bPower>=prevAmari){
					bPower = bPower - prevAmari;
				}else{
					bPower = 0;
				}
			} prevAmari>=0 prevAmari 0 {
				if(bPower>=prevAmari){
					bPower = bPower - prevAmari;
				}else{
					bPower = 0;
				}
			} if(bPower>=prevAmari){
					bPower = bPower - prevAmari;
				}else{
					bPower = 0;
				} bPower>=prevAmari bPower prevAmari {
					bPower = bPower - prevAmari;
				} bPower = bPower - prevAmari bPower bPower - prevAmari bPower prevAmari {
					bPower = 0;
				} bPower = 0 bPower 0 if(bPower >= ai){
				prevAmari =0;
				resultSum -= bPower-ai;
			}else{
				prevAmari = ai - bPower;
			} bPower >= ai bPower ai {
				prevAmari =0;
				resultSum -= bPower-ai;
			} prevAmari =0 prevAmari 0 resultSum -= bPower-ai resultSum bPower-ai bPower ai {
				prevAmari = ai - bPower;
			} prevAmari = ai - bPower prevAmari ai - bPower ai bPower System.out.println(resultSum) System.out.println System.out System System.out resultSum String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		long resultSum =0;
		List<Long> aList = new ArrayList<>(n+1);
		List<Long> bList = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			long a = Long.parseLong(sc.next());
			aList.add(a);
		}
		aList.add(Long.parseLong(sc.next()));

		for (int i = 0; i < n; i++) {
			long b = Long.parseLong(sc.next());
			bList.add(b);
			resultSum += b;
		}


		// System.out.println("aList " + aList);

		// System.out.println("bList " + bList);

		long prevAmari  = aList.get(n);
		for (int i = n-1; i >= 0 ; i--) {
			// System.out.println("i " + i);

			long b = bList.get(i);
			long ai = aList.get(i);
			long bPower = b;
			if(prevAmari>=0){
				if(bPower>=prevAmari){
					bPower = bPower - prevAmari;
				}else{
					bPower = 0;
				}
			}

			if(bPower >= ai){
				prevAmari =0;
				resultSum -= bPower-ai;
			}else{
				prevAmari = ai - bPower;
			}
			// System.out.println("b " + b);
			// System.out.println("ai " + ai);

			// System.out.println("prevAmari " + prevAmari);
			// System.out.println("bPower " + bPower);
			// System.out.println("resultSum " + resultSum);
		}
		System.out.println(resultSum);


	}

} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		long resultSum =0;
		List<Long> aList = new ArrayList<>(n+1);
		List<Long> bList = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			long a = Long.parseLong(sc.next());
			aList.add(a);
		}
		aList.add(Long.parseLong(sc.next()));

		for (int i = 0; i < n; i++) {
			long b = Long.parseLong(sc.next());
			bList.add(b);
			resultSum += b;
		}


		// System.out.println("aList " + aList);

		// System.out.println("bList " + bList);

		long prevAmari  = aList.get(n);
		for (int i = n-1; i >= 0 ; i--) {
			// System.out.println("i " + i);

			long b = bList.get(i);
			long ai = aList.get(i);
			long bPower = b;
			if(prevAmari>=0){
				if(bPower>=prevAmari){
					bPower = bPower - prevAmari;
				}else{
					bPower = 0;
				}
			}

			if(bPower >= ai){
				prevAmari =0;
				resultSum -= bPower-ai;
			}else{
				prevAmari = ai - bPower;
			}
			// System.out.println("b " + b);
			// System.out.println("ai " + ai);

			// System.out.println("prevAmari " + prevAmari);
			// System.out.println("bPower " + bPower);
			// System.out.println("resultSum " + resultSum);
		}
		System.out.println(resultSum);


	}

} Main
import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		long resultSum =0;
		List<Long> aList = new ArrayList<>(n+1);
		List<Long> bList = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			long a = Long.parseLong(sc.next());
			aList.add(a);
		}
		aList.add(Long.parseLong(sc.next()));

		for (int i = 0; i < n; i++) {
			long b = Long.parseLong(sc.next());
			bList.add(b);
			resultSum += b;
		}


		// System.out.println("aList " + aList);

		// System.out.println("bList " + bList);

		long prevAmari  = aList.get(n);
		for (int i = n-1; i >= 0 ; i--) {
			// System.out.println("i " + i);

			long b = bList.get(i);
			long ai = aList.get(i);
			long bPower = b;
			if(prevAmari>=0){
				if(bPower>=prevAmari){
					bPower = bPower - prevAmari;
				}else{
					bPower = 0;
				}
			}

			if(bPower >= ai){
				prevAmari =0;
				resultSum -= bPower-ai;
			}else{
				prevAmari = ai - bPower;
			}
			// System.out.println("b " + b);
			// System.out.println("ai " + ai);

			// System.out.println("prevAmari " + prevAmari);
			// System.out.println("bPower " + bPower);
			// System.out.println("resultSum " + resultSum);
		}
		System.out.println(resultSum);


	}

}
