import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		int N = Integer.parseInt(W) +1;
		long[] A = new long[N];
		long[] B = new long[N];


		W = in.readLine();
		String[] Ws = W.split(" ");
		for(int i=0;i<N;i++){
			A[i] = Long.parseLong(Ws[i]);
		}

		W = in.readLine();
		Ws = W.split(" ");
		for(int i=0;i<N-1;i++){
			B[i] = Long.parseLong(Ws[i]);
		}
		B[N-1]=0;

		long destory=0;
		long diff=0;
		for(int i=0;i<N;i++){
			//A[i-1]の勇者が何体倒せるか
			if(diff >= A[i]){
				//全部倒せるなら戦力を次に残す
				diff=B[i];
				destory+=A[i];
			}else{
				//倒せない場合は残りをA[i]で倒す
				long remain = A[i] -diff;
				destory+=diff;
				//A[i]の戦力ですべて倒せるか
				if(remain <= B[i]){
					//倒せる場合は次に残す戦力を計算する
					diff=B[i]-remain;
					destory+=remain;
				}else{
					//倒せない場合は倒せる数だけ倒す
					diff=0;
					destory+=B[i];

				}
			}
		}
		System.out.println(destory);


	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		int N = Integer.parseInt(W) +1;
		long[] A = new long[N];
		long[] B = new long[N];


		W = in.readLine();
		String[] Ws = W.split(" ");
		for(int i=0;i<N;i++){
			A[i] = Long.parseLong(Ws[i]);
		}

		W = in.readLine();
		Ws = W.split(" ");
		for(int i=0;i<N-1;i++){
			B[i] = Long.parseLong(Ws[i]);
		}
		B[N-1]=0;

		long destory=0;
		long diff=0;
		for(int i=0;i<N;i++){
			//A[i-1]の勇者が何体倒せるか
			if(diff >= A[i]){
				//全部倒せるなら戦力を次に残す
				diff=B[i];
				destory+=A[i];
			}else{
				//倒せない場合は残りをA[i]で倒す
				long remain = A[i] -diff;
				destory+=diff;
				//A[i]の戦力ですべて倒せるか
				if(remain <= B[i]){
					//倒せる場合は次に残す戦力を計算する
					diff=B[i]-remain;
					destory+=remain;
				}else{
					//倒せない場合は倒せる数だけ倒す
					diff=0;
					destory+=B[i];

				}
			}
		}
		System.out.println(destory);


	}

} Main public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		int N = Integer.parseInt(W) +1;
		long[] A = new long[N];
		long[] B = new long[N];


		W = in.readLine();
		String[] Ws = W.split(" ");
		for(int i=0;i<N;i++){
			A[i] = Long.parseLong(Ws[i]);
		}

		W = in.readLine();
		Ws = W.split(" ");
		for(int i=0;i<N-1;i++){
			B[i] = Long.parseLong(Ws[i]);
		}
		B[N-1]=0;

		long destory=0;
		long diff=0;
		for(int i=0;i<N;i++){
			//A[i-1]の勇者が何体倒せるか
			if(diff >= A[i]){
				//全部倒せるなら戦力を次に残す
				diff=B[i];
				destory+=A[i];
			}else{
				//倒せない場合は残りをA[i]で倒す
				long remain = A[i] -diff;
				destory+=diff;
				//A[i]の戦力ですべて倒せるか
				if(remain <= B[i]){
					//倒せる場合は次に残す戦力を計算する
					diff=B[i]-remain;
					destory+=remain;
				}else{
					//倒せない場合は倒せる数だけ倒す
					diff=0;
					destory+=B[i];

				}
			}
		}
		System.out.println(destory);


	} main {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		int N = Integer.parseInt(W) +1;
		long[] A = new long[N];
		long[] B = new long[N];


		W = in.readLine();
		String[] Ws = W.split(" ");
		for(int i=0;i<N;i++){
			A[i] = Long.parseLong(Ws[i]);
		}

		W = in.readLine();
		Ws = W.split(" ");
		for(int i=0;i<N-1;i++){
			B[i] = Long.parseLong(Ws[i]);
		}
		B[N-1]=0;

		long destory=0;
		long diff=0;
		for(int i=0;i<N;i++){
			//A[i-1]の勇者が何体倒せるか
			if(diff >= A[i]){
				//全部倒せるなら戦力を次に残す
				diff=B[i];
				destory+=A[i];
			}else{
				//倒せない場合は残りをA[i]で倒す
				long remain = A[i] -diff;
				destory+=diff;
				//A[i]の戦力ですべて倒せるか
				if(remain <= B[i]){
					//倒せる場合は次に残す戦力を計算する
					diff=B[i]-remain;
					destory+=remain;
				}else{
					//倒せない場合は倒せる数だけ倒す
					diff=0;
					destory+=B[i];

				}
			}
		}
		System.out.println(destory);


	} BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) String W = in.readLine(); W in.readLine() in.readLine in int N = Integer.parseInt(W) +1; N Integer.parseInt(W) +1 Integer.parseInt(W) Integer.parseInt Integer W 1 long[] A = new long[N]; A new long[N] N long[] B = new long[N]; B new long[N] N W = in.readLine() W in.readLine() in.readLine in String[] Ws = W.split(" "); Ws W.split(" ") W.split W " " for(int i=0;i<N;i++){
			A[i] = Long.parseLong(Ws[i]);
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			A[i] = Long.parseLong(Ws[i]);
		} {
			A[i] = Long.parseLong(Ws[i]);
		} A[i] = Long.parseLong(Ws[i]) A[i] A i Long.parseLong(Ws[i]) Long.parseLong Long Ws[i] Ws i W = in.readLine() W in.readLine() in.readLine in Ws = W.split(" ") Ws W.split(" ") W.split W " " for(int i=0;i<N-1;i++){
			B[i] = Long.parseLong(Ws[i]);
		} int i=0; int i=0; i 0 i<N-1 i N-1 N 1 i++ i++ i {
			B[i] = Long.parseLong(Ws[i]);
		} {
			B[i] = Long.parseLong(Ws[i]);
		} B[i] = Long.parseLong(Ws[i]) B[i] B i Long.parseLong(Ws[i]) Long.parseLong Long Ws[i] Ws i B[N-1]=0 B[N-1] B N-1 N 1 0 long destory=0; destory 0 long diff=0; diff 0 for(int i=0;i<N;i++){
			//A[i-1]の勇者が何体倒せるか
			if(diff >= A[i]){
				//全部倒せるなら戦力を次に残す
				diff=B[i];
				destory+=A[i];
			}else{
				//倒せない場合は残りをA[i]で倒す
				long remain = A[i] -diff;
				destory+=diff;
				//A[i]の戦力ですべて倒せるか
				if(remain <= B[i]){
					//倒せる場合は次に残す戦力を計算する
					diff=B[i]-remain;
					destory+=remain;
				}else{
					//倒せない場合は倒せる数だけ倒す
					diff=0;
					destory+=B[i];

				}
			}
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			//A[i-1]の勇者が何体倒せるか
			if(diff >= A[i]){
				//全部倒せるなら戦力を次に残す
				diff=B[i];
				destory+=A[i];
			}else{
				//倒せない場合は残りをA[i]で倒す
				long remain = A[i] -diff;
				destory+=diff;
				//A[i]の戦力ですべて倒せるか
				if(remain <= B[i]){
					//倒せる場合は次に残す戦力を計算する
					diff=B[i]-remain;
					destory+=remain;
				}else{
					//倒せない場合は倒せる数だけ倒す
					diff=0;
					destory+=B[i];

				}
			}
		} {
			//A[i-1]の勇者が何体倒せるか
			if(diff >= A[i]){
				//全部倒せるなら戦力を次に残す
				diff=B[i];
				destory+=A[i];
			}else{
				//倒せない場合は残りをA[i]で倒す
				long remain = A[i] -diff;
				destory+=diff;
				//A[i]の戦力ですべて倒せるか
				if(remain <= B[i]){
					//倒せる場合は次に残す戦力を計算する
					diff=B[i]-remain;
					destory+=remain;
				}else{
					//倒せない場合は倒せる数だけ倒す
					diff=0;
					destory+=B[i];

				}
			}
		} if(diff >= A[i]){
				//全部倒せるなら戦力を次に残す
				diff=B[i];
				destory+=A[i];
			}else{
				//倒せない場合は残りをA[i]で倒す
				long remain = A[i] -diff;
				destory+=diff;
				//A[i]の戦力ですべて倒せるか
				if(remain <= B[i]){
					//倒せる場合は次に残す戦力を計算する
					diff=B[i]-remain;
					destory+=remain;
				}else{
					//倒せない場合は倒せる数だけ倒す
					diff=0;
					destory+=B[i];

				}
			} diff >= A[i] diff A[i] A i {
				//全部倒せるなら戦力を次に残す
				diff=B[i];
				destory+=A[i];
			} diff=B[i] diff B[i] B i destory+=A[i] destory A[i] A i {
				//倒せない場合は残りをA[i]で倒す
				long remain = A[i] -diff;
				destory+=diff;
				//A[i]の戦力ですべて倒せるか
				if(remain <= B[i]){
					//倒せる場合は次に残す戦力を計算する
					diff=B[i]-remain;
					destory+=remain;
				}else{
					//倒せない場合は倒せる数だけ倒す
					diff=0;
					destory+=B[i];

				}
			} long remain = A[i] -diff; remain A[i] -diff A[i] A i diff destory+=diff destory diff if(remain <= B[i]){
					//倒せる場合は次に残す戦力を計算する
					diff=B[i]-remain;
					destory+=remain;
				}else{
					//倒せない場合は倒せる数だけ倒す
					diff=0;
					destory+=B[i];

				} remain <= B[i] remain B[i] B i {
					//倒せる場合は次に残す戦力を計算する
					diff=B[i]-remain;
					destory+=remain;
				} diff=B[i]-remain diff B[i]-remain B[i] B i remain destory+=remain destory remain {
					//倒せない場合は倒せる数だけ倒す
					diff=0;
					destory+=B[i];

				} diff=0 diff 0 destory+=B[i] destory B[i] B i System.out.println(destory) System.out.println System.out System System.out destory String[] args args public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		int N = Integer.parseInt(W) +1;
		long[] A = new long[N];
		long[] B = new long[N];


		W = in.readLine();
		String[] Ws = W.split(" ");
		for(int i=0;i<N;i++){
			A[i] = Long.parseLong(Ws[i]);
		}

		W = in.readLine();
		Ws = W.split(" ");
		for(int i=0;i<N-1;i++){
			B[i] = Long.parseLong(Ws[i]);
		}
		B[N-1]=0;

		long destory=0;
		long diff=0;
		for(int i=0;i<N;i++){
			//A[i-1]の勇者が何体倒せるか
			if(diff >= A[i]){
				//全部倒せるなら戦力を次に残す
				diff=B[i];
				destory+=A[i];
			}else{
				//倒せない場合は残りをA[i]で倒す
				long remain = A[i] -diff;
				destory+=diff;
				//A[i]の戦力ですべて倒せるか
				if(remain <= B[i]){
					//倒せる場合は次に残す戦力を計算する
					diff=B[i]-remain;
					destory+=remain;
				}else{
					//倒せない場合は倒せる数だけ倒す
					diff=0;
					destory+=B[i];

				}
			}
		}
		System.out.println(destory);


	}

} public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		int N = Integer.parseInt(W) +1;
		long[] A = new long[N];
		long[] B = new long[N];


		W = in.readLine();
		String[] Ws = W.split(" ");
		for(int i=0;i<N;i++){
			A[i] = Long.parseLong(Ws[i]);
		}

		W = in.readLine();
		Ws = W.split(" ");
		for(int i=0;i<N-1;i++){
			B[i] = Long.parseLong(Ws[i]);
		}
		B[N-1]=0;

		long destory=0;
		long diff=0;
		for(int i=0;i<N;i++){
			//A[i-1]の勇者が何体倒せるか
			if(diff >= A[i]){
				//全部倒せるなら戦力を次に残す
				diff=B[i];
				destory+=A[i];
			}else{
				//倒せない場合は残りをA[i]で倒す
				long remain = A[i] -diff;
				destory+=diff;
				//A[i]の戦力ですべて倒せるか
				if(remain <= B[i]){
					//倒せる場合は次に残す戦力を計算する
					diff=B[i]-remain;
					destory+=remain;
				}else{
					//倒せない場合は倒せる数だけ倒す
					diff=0;
					destory+=B[i];

				}
			}
		}
		System.out.println(destory);


	}

} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		int N = Integer.parseInt(W) +1;
		long[] A = new long[N];
		long[] B = new long[N];


		W = in.readLine();
		String[] Ws = W.split(" ");
		for(int i=0;i<N;i++){
			A[i] = Long.parseLong(Ws[i]);
		}

		W = in.readLine();
		Ws = W.split(" ");
		for(int i=0;i<N-1;i++){
			B[i] = Long.parseLong(Ws[i]);
		}
		B[N-1]=0;

		long destory=0;
		long diff=0;
		for(int i=0;i<N;i++){
			//A[i-1]の勇者が何体倒せるか
			if(diff >= A[i]){
				//全部倒せるなら戦力を次に残す
				diff=B[i];
				destory+=A[i];
			}else{
				//倒せない場合は残りをA[i]で倒す
				long remain = A[i] -diff;
				destory+=diff;
				//A[i]の戦力ですべて倒せるか
				if(remain <= B[i]){
					//倒せる場合は次に残す戦力を計算する
					diff=B[i]-remain;
					destory+=remain;
				}else{
					//倒せない場合は倒せる数だけ倒す
					diff=0;
					destory+=B[i];

				}
			}
		}
		System.out.println(destory);


	}

}
