import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int[] A = new int[N + 1];
		long sum = 0;
		for (int i = 0; i <= N; i++) {
			A[i] = sc.nextInt();
			sum += A[i];
		}
		int[] B = new int[N];
		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}
		for(int i=0;i<N;i++) {
			if(B[i]>=A[i]) {
				B[i]-=A[i];
				A[i]=0;
				if(B[i]>=A[i+1]) {
					A[i+1]=0;
				} else {
					A[i+1] -= B[i];
				}
			} else {
				A[i] -=B[i];
			}
		}
		long sum2 = 0;
		for (int i = 0; i <= N; i++) {
			sum2 += A[i];
		}
		System.out.println(sum-sum2);

	}
} import java.io.FileNotFoundException; FileNotFoundException java.io import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int[] A = new int[N + 1];
		long sum = 0;
		for (int i = 0; i <= N; i++) {
			A[i] = sc.nextInt();
			sum += A[i];
		}
		int[] B = new int[N];
		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}
		for(int i=0;i<N;i++) {
			if(B[i]>=A[i]) {
				B[i]-=A[i];
				A[i]=0;
				if(B[i]>=A[i+1]) {
					A[i+1]=0;
				} else {
					A[i+1] -= B[i];
				}
			} else {
				A[i] -=B[i];
			}
		}
		long sum2 = 0;
		for (int i = 0; i <= N; i++) {
			sum2 += A[i];
		}
		System.out.println(sum-sum2);

	}
} Main public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int[] A = new int[N + 1];
		long sum = 0;
		for (int i = 0; i <= N; i++) {
			A[i] = sc.nextInt();
			sum += A[i];
		}
		int[] B = new int[N];
		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}
		for(int i=0;i<N;i++) {
			if(B[i]>=A[i]) {
				B[i]-=A[i];
				A[i]=0;
				if(B[i]>=A[i+1]) {
					A[i+1]=0;
				} else {
					A[i+1] -= B[i];
				}
			} else {
				A[i] -=B[i];
			}
		}
		long sum2 = 0;
		for (int i = 0; i <= N; i++) {
			sum2 += A[i];
		}
		System.out.println(sum-sum2);

	} main {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int[] A = new int[N + 1];
		long sum = 0;
		for (int i = 0; i <= N; i++) {
			A[i] = sc.nextInt();
			sum += A[i];
		}
		int[] B = new int[N];
		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}
		for(int i=0;i<N;i++) {
			if(B[i]>=A[i]) {
				B[i]-=A[i];
				A[i]=0;
				if(B[i]>=A[i+1]) {
					A[i+1]=0;
				} else {
					A[i+1] -= B[i];
				}
			} else {
				A[i] -=B[i];
			}
		}
		long sum2 = 0;
		for (int i = 0; i <= N; i++) {
			sum2 += A[i];
		}
		System.out.println(sum-sum2);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] A = new int[N + 1]; A new int[N + 1] N + 1 N 1 long sum = 0; sum 0 for (int i = 0; i <= N; i++) {
			A[i] = sc.nextInt();
			sum += A[i];
		} int i = 0; int i = 0; i 0 i <= N i N i++ i++ i {
			A[i] = sc.nextInt();
			sum += A[i];
		} {
			A[i] = sc.nextInt();
			sum += A[i];
		} A[i] = sc.nextInt() A[i] A i sc.nextInt() sc.nextInt sc sum += A[i] sum A[i] A i int[] B = new int[N]; B new int[N] N for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			B[i] = sc.nextInt();
		} {
			B[i] = sc.nextInt();
		} B[i] = sc.nextInt() B[i] B i sc.nextInt() sc.nextInt sc for(int i=0;i<N;i++) {
			if(B[i]>=A[i]) {
				B[i]-=A[i];
				A[i]=0;
				if(B[i]>=A[i+1]) {
					A[i+1]=0;
				} else {
					A[i+1] -= B[i];
				}
			} else {
				A[i] -=B[i];
			}
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			if(B[i]>=A[i]) {
				B[i]-=A[i];
				A[i]=0;
				if(B[i]>=A[i+1]) {
					A[i+1]=0;
				} else {
					A[i+1] -= B[i];
				}
			} else {
				A[i] -=B[i];
			}
		} {
			if(B[i]>=A[i]) {
				B[i]-=A[i];
				A[i]=0;
				if(B[i]>=A[i+1]) {
					A[i+1]=0;
				} else {
					A[i+1] -= B[i];
				}
			} else {
				A[i] -=B[i];
			}
		} if(B[i]>=A[i]) {
				B[i]-=A[i];
				A[i]=0;
				if(B[i]>=A[i+1]) {
					A[i+1]=0;
				} else {
					A[i+1] -= B[i];
				}
			} else {
				A[i] -=B[i];
			} B[i]>=A[i] B[i] B i A[i] A i {
				B[i]-=A[i];
				A[i]=0;
				if(B[i]>=A[i+1]) {
					A[i+1]=0;
				} else {
					A[i+1] -= B[i];
				}
			} B[i]-=A[i] B[i] B i A[i] A i A[i]=0 A[i] A i 0 if(B[i]>=A[i+1]) {
					A[i+1]=0;
				} else {
					A[i+1] -= B[i];
				} B[i]>=A[i+1] B[i] B i A[i+1] A i+1 i 1 {
					A[i+1]=0;
				} A[i+1]=0 A[i+1] A i+1 i 1 0 {
					A[i+1] -= B[i];
				} A[i+1] -= B[i] A[i+1] A i+1 i 1 B[i] B i {
				A[i] -=B[i];
			} A[i] -=B[i] A[i] A i B[i] B i long sum2 = 0; sum2 0 for (int i = 0; i <= N; i++) {
			sum2 += A[i];
		} int i = 0; int i = 0; i 0 i <= N i N i++ i++ i {
			sum2 += A[i];
		} {
			sum2 += A[i];
		} sum2 += A[i] sum2 A[i] A i System.out.println(sum-sum2) System.out.println System.out System System.out sum-sum2 sum sum2 String[] args args public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int[] A = new int[N + 1];
		long sum = 0;
		for (int i = 0; i <= N; i++) {
			A[i] = sc.nextInt();
			sum += A[i];
		}
		int[] B = new int[N];
		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}
		for(int i=0;i<N;i++) {
			if(B[i]>=A[i]) {
				B[i]-=A[i];
				A[i]=0;
				if(B[i]>=A[i+1]) {
					A[i+1]=0;
				} else {
					A[i+1] -= B[i];
				}
			} else {
				A[i] -=B[i];
			}
		}
		long sum2 = 0;
		for (int i = 0; i <= N; i++) {
			sum2 += A[i];
		}
		System.out.println(sum-sum2);

	}
} public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int[] A = new int[N + 1];
		long sum = 0;
		for (int i = 0; i <= N; i++) {
			A[i] = sc.nextInt();
			sum += A[i];
		}
		int[] B = new int[N];
		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}
		for(int i=0;i<N;i++) {
			if(B[i]>=A[i]) {
				B[i]-=A[i];
				A[i]=0;
				if(B[i]>=A[i+1]) {
					A[i+1]=0;
				} else {
					A[i+1] -= B[i];
				}
			} else {
				A[i] -=B[i];
			}
		}
		long sum2 = 0;
		for (int i = 0; i <= N; i++) {
			sum2 += A[i];
		}
		System.out.println(sum-sum2);

	}
} Main
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int[] A = new int[N + 1];
		long sum = 0;
		for (int i = 0; i <= N; i++) {
			A[i] = sc.nextInt();
			sum += A[i];
		}
		int[] B = new int[N];
		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}
		for(int i=0;i<N;i++) {
			if(B[i]>=A[i]) {
				B[i]-=A[i];
				A[i]=0;
				if(B[i]>=A[i+1]) {
					A[i+1]=0;
				} else {
					A[i+1] -= B[i];
				}
			} else {
				A[i] -=B[i];
			}
		}
		long sum2 = 0;
		for (int i = 0; i <= N; i++) {
			sum2 += A[i];
		}
		System.out.println(sum-sum2);

	}
}
