import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		long[] a = new long[N+1];
		for(int i=0; i<N+1; i++) {
			a[i] = sc.nextLong();
		}

		long[] b = new long[N];
		for(int i=0; i<N; i++) {
			b[i] = sc.nextLong();
		}

		sc.close();

		long cnt=0, tmp = 0;
		for(int i=0; i<N; i++) {

			if(i==0) {
				cnt += Math.min(a[i], b[i]);
				tmp = Math.min(a[i+1],b[i] - Math.min(a[i],b[i]));
				cnt += tmp;
			}

			if(i!=0) {
				cnt += Math.min(a[i] - tmp, b[i]);
				tmp = Math.min(a[i+1],b[i] - Math.min(a[i] - tmp, b[i]));
				cnt += tmp;
			}
		}

		System.out.println(cnt);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		long[] a = new long[N+1];
		for(int i=0; i<N+1; i++) {
			a[i] = sc.nextLong();
		}

		long[] b = new long[N];
		for(int i=0; i<N; i++) {
			b[i] = sc.nextLong();
		}

		sc.close();

		long cnt=0, tmp = 0;
		for(int i=0; i<N; i++) {

			if(i==0) {
				cnt += Math.min(a[i], b[i]);
				tmp = Math.min(a[i+1],b[i] - Math.min(a[i],b[i]));
				cnt += tmp;
			}

			if(i!=0) {
				cnt += Math.min(a[i] - tmp, b[i]);
				tmp = Math.min(a[i+1],b[i] - Math.min(a[i] - tmp, b[i]));
				cnt += tmp;
			}
		}

		System.out.println(cnt);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		long[] a = new long[N+1];
		for(int i=0; i<N+1; i++) {
			a[i] = sc.nextLong();
		}

		long[] b = new long[N];
		for(int i=0; i<N; i++) {
			b[i] = sc.nextLong();
		}

		sc.close();

		long cnt=0, tmp = 0;
		for(int i=0; i<N; i++) {

			if(i==0) {
				cnt += Math.min(a[i], b[i]);
				tmp = Math.min(a[i+1],b[i] - Math.min(a[i],b[i]));
				cnt += tmp;
			}

			if(i!=0) {
				cnt += Math.min(a[i] - tmp, b[i]);
				tmp = Math.min(a[i+1],b[i] - Math.min(a[i] - tmp, b[i]));
				cnt += tmp;
			}
		}

		System.out.println(cnt);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		long[] a = new long[N+1];
		for(int i=0; i<N+1; i++) {
			a[i] = sc.nextLong();
		}

		long[] b = new long[N];
		for(int i=0; i<N; i++) {
			b[i] = sc.nextLong();
		}

		sc.close();

		long cnt=0, tmp = 0;
		for(int i=0; i<N; i++) {

			if(i==0) {
				cnt += Math.min(a[i], b[i]);
				tmp = Math.min(a[i+1],b[i] - Math.min(a[i],b[i]));
				cnt += tmp;
			}

			if(i!=0) {
				cnt += Math.min(a[i] - tmp, b[i]);
				tmp = Math.min(a[i+1],b[i] - Math.min(a[i] - tmp, b[i]));
				cnt += tmp;
			}
		}

		System.out.println(cnt);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc long[] a = new long[N+1]; a new long[N+1] N+1 N 1 for(int i=0; i<N+1; i++) {
			a[i] = sc.nextLong();
		} int i=0; int i=0; i 0 i<N+1 i N+1 N 1 i++ i++ i {
			a[i] = sc.nextLong();
		} {
			a[i] = sc.nextLong();
		} a[i] = sc.nextLong() a[i] a i sc.nextLong() sc.nextLong sc long[] b = new long[N]; b new long[N] N for(int i=0; i<N; i++) {
			b[i] = sc.nextLong();
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			b[i] = sc.nextLong();
		} {
			b[i] = sc.nextLong();
		} b[i] = sc.nextLong() b[i] b i sc.nextLong() sc.nextLong sc sc.close() sc.close sc long cnt=0 cnt 0 tmp = 0; tmp 0 for(int i=0; i<N; i++) {

			if(i==0) {
				cnt += Math.min(a[i], b[i]);
				tmp = Math.min(a[i+1],b[i] - Math.min(a[i],b[i]));
				cnt += tmp;
			}

			if(i!=0) {
				cnt += Math.min(a[i] - tmp, b[i]);
				tmp = Math.min(a[i+1],b[i] - Math.min(a[i] - tmp, b[i]));
				cnt += tmp;
			}
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {

			if(i==0) {
				cnt += Math.min(a[i], b[i]);
				tmp = Math.min(a[i+1],b[i] - Math.min(a[i],b[i]));
				cnt += tmp;
			}

			if(i!=0) {
				cnt += Math.min(a[i] - tmp, b[i]);
				tmp = Math.min(a[i+1],b[i] - Math.min(a[i] - tmp, b[i]));
				cnt += tmp;
			}
		} {

			if(i==0) {
				cnt += Math.min(a[i], b[i]);
				tmp = Math.min(a[i+1],b[i] - Math.min(a[i],b[i]));
				cnt += tmp;
			}

			if(i!=0) {
				cnt += Math.min(a[i] - tmp, b[i]);
				tmp = Math.min(a[i+1],b[i] - Math.min(a[i] - tmp, b[i]));
				cnt += tmp;
			}
		} if(i==0) {
				cnt += Math.min(a[i], b[i]);
				tmp = Math.min(a[i+1],b[i] - Math.min(a[i],b[i]));
				cnt += tmp;
			} i==0 i 0 {
				cnt += Math.min(a[i], b[i]);
				tmp = Math.min(a[i+1],b[i] - Math.min(a[i],b[i]));
				cnt += tmp;
			} cnt += Math.min(a[i], b[i]) cnt Math.min(a[i], b[i]) Math.min Math a[i] a i b[i] b i tmp = Math.min(a[i+1],b[i] - Math.min(a[i],b[i])) tmp Math.min(a[i+1],b[i] - Math.min(a[i],b[i])) Math.min Math a[i+1] a i+1 i 1 b[i] - Math.min(a[i],b[i]) b[i] b i Math.min(a[i],b[i]) Math.min Math a[i] a i b[i] b i cnt += tmp cnt tmp if(i!=0) {
				cnt += Math.min(a[i] - tmp, b[i]);
				tmp = Math.min(a[i+1],b[i] - Math.min(a[i] - tmp, b[i]));
				cnt += tmp;
			} i!=0 i 0 {
				cnt += Math.min(a[i] - tmp, b[i]);
				tmp = Math.min(a[i+1],b[i] - Math.min(a[i] - tmp, b[i]));
				cnt += tmp;
			} cnt += Math.min(a[i] - tmp, b[i]) cnt Math.min(a[i] - tmp, b[i]) Math.min Math a[i] - tmp a[i] a i tmp b[i] b i tmp = Math.min(a[i+1],b[i] - Math.min(a[i] - tmp, b[i])) tmp Math.min(a[i+1],b[i] - Math.min(a[i] - tmp, b[i])) Math.min Math a[i+1] a i+1 i 1 b[i] - Math.min(a[i] - tmp, b[i]) b[i] b i Math.min(a[i] - tmp, b[i]) Math.min Math a[i] - tmp a[i] a i tmp b[i] b i cnt += tmp cnt tmp System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		long[] a = new long[N+1];
		for(int i=0; i<N+1; i++) {
			a[i] = sc.nextLong();
		}

		long[] b = new long[N];
		for(int i=0; i<N; i++) {
			b[i] = sc.nextLong();
		}

		sc.close();

		long cnt=0, tmp = 0;
		for(int i=0; i<N; i++) {

			if(i==0) {
				cnt += Math.min(a[i], b[i]);
				tmp = Math.min(a[i+1],b[i] - Math.min(a[i],b[i]));
				cnt += tmp;
			}

			if(i!=0) {
				cnt += Math.min(a[i] - tmp, b[i]);
				tmp = Math.min(a[i+1],b[i] - Math.min(a[i] - tmp, b[i]));
				cnt += tmp;
			}
		}

		System.out.println(cnt);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		long[] a = new long[N+1];
		for(int i=0; i<N+1; i++) {
			a[i] = sc.nextLong();
		}

		long[] b = new long[N];
		for(int i=0; i<N; i++) {
			b[i] = sc.nextLong();
		}

		sc.close();

		long cnt=0, tmp = 0;
		for(int i=0; i<N; i++) {

			if(i==0) {
				cnt += Math.min(a[i], b[i]);
				tmp = Math.min(a[i+1],b[i] - Math.min(a[i],b[i]));
				cnt += tmp;
			}

			if(i!=0) {
				cnt += Math.min(a[i] - tmp, b[i]);
				tmp = Math.min(a[i+1],b[i] - Math.min(a[i] - tmp, b[i]));
				cnt += tmp;
			}
		}

		System.out.println(cnt);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		long[] a = new long[N+1];
		for(int i=0; i<N+1; i++) {
			a[i] = sc.nextLong();
		}

		long[] b = new long[N];
		for(int i=0; i<N; i++) {
			b[i] = sc.nextLong();
		}

		sc.close();

		long cnt=0, tmp = 0;
		for(int i=0; i<N; i++) {

			if(i==0) {
				cnt += Math.min(a[i], b[i]);
				tmp = Math.min(a[i+1],b[i] - Math.min(a[i],b[i]));
				cnt += tmp;
			}

			if(i!=0) {
				cnt += Math.min(a[i] - tmp, b[i]);
				tmp = Math.min(a[i+1],b[i] - Math.min(a[i] - tmp, b[i]));
				cnt += tmp;
			}
		}

		System.out.println(cnt);
	}
}