import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n =scan.nextInt();
		int a[]=new int[n+1];
		int b[]=new int[n];
		for(int i=0;i<n+1;i++) {
			a[i]=scan.nextInt();
		}
		for(int i=0;i<n;i++) {
			b[i]=scan.nextInt();
		}
		scan.close();

		long sum=0;
		for(int i=0;i<n;i++) {
			int x=Math.min(b[i],a[i]);
			sum+=x;
			x=Math.min(b[i]-x,a[i+1]);
			a[i+1]-=x;
			sum+=x;
		}
		System.out.println(sum);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n =scan.nextInt();
		int a[]=new int[n+1];
		int b[]=new int[n];
		for(int i=0;i<n+1;i++) {
			a[i]=scan.nextInt();
		}
		for(int i=0;i<n;i++) {
			b[i]=scan.nextInt();
		}
		scan.close();

		long sum=0;
		for(int i=0;i<n;i++) {
			int x=Math.min(b[i],a[i]);
			sum+=x;
			x=Math.min(b[i]-x,a[i+1]);
			a[i+1]-=x;
			sum+=x;
		}
		System.out.println(sum);
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n =scan.nextInt();
		int a[]=new int[n+1];
		int b[]=new int[n];
		for(int i=0;i<n+1;i++) {
			a[i]=scan.nextInt();
		}
		for(int i=0;i<n;i++) {
			b[i]=scan.nextInt();
		}
		scan.close();

		long sum=0;
		for(int i=0;i<n;i++) {
			int x=Math.min(b[i],a[i]);
			sum+=x;
			x=Math.min(b[i]-x,a[i+1]);
			a[i+1]-=x;
			sum+=x;
		}
		System.out.println(sum);
	} main {
		Scanner scan = new Scanner(System.in);
		int n =scan.nextInt();
		int a[]=new int[n+1];
		int b[]=new int[n];
		for(int i=0;i<n+1;i++) {
			a[i]=scan.nextInt();
		}
		for(int i=0;i<n;i++) {
			b[i]=scan.nextInt();
		}
		scan.close();

		long sum=0;
		for(int i=0;i<n;i++) {
			int x=Math.min(b[i],a[i]);
			sum+=x;
			x=Math.min(b[i]-x,a[i+1]);
			a[i+1]-=x;
			sum+=x;
		}
		System.out.println(sum);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n =scan.nextInt(); n scan.nextInt() scan.nextInt scan int a[]=new int[n+1]; a new int[n+1] n+1 n 1 int b[]=new int[n]; b new int[n] n for(int i=0;i<n+1;i++) {
			a[i]=scan.nextInt();
		} int i=0; int i=0; i 0 i<n+1 i n+1 n 1 i++ i++ i {
			a[i]=scan.nextInt();
		} {
			a[i]=scan.nextInt();
		} a[i]=scan.nextInt() a[i] a i scan.nextInt() scan.nextInt scan for(int i=0;i<n;i++) {
			b[i]=scan.nextInt();
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			b[i]=scan.nextInt();
		} {
			b[i]=scan.nextInt();
		} b[i]=scan.nextInt() b[i] b i scan.nextInt() scan.nextInt scan scan.close() scan.close scan long sum=0; sum 0 for(int i=0;i<n;i++) {
			int x=Math.min(b[i],a[i]);
			sum+=x;
			x=Math.min(b[i]-x,a[i+1]);
			a[i+1]-=x;
			sum+=x;
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			int x=Math.min(b[i],a[i]);
			sum+=x;
			x=Math.min(b[i]-x,a[i+1]);
			a[i+1]-=x;
			sum+=x;
		} {
			int x=Math.min(b[i],a[i]);
			sum+=x;
			x=Math.min(b[i]-x,a[i+1]);
			a[i+1]-=x;
			sum+=x;
		} int x=Math.min(b[i],a[i]); x Math.min(b[i],a[i]) Math.min Math b[i] b i a[i] a i sum+=x sum x x=Math.min(b[i]-x,a[i+1]) x Math.min(b[i]-x,a[i+1]) Math.min Math b[i]-x b[i] b i x a[i+1] a i+1 i 1 a[i+1]-=x a[i+1] a i+1 i 1 x sum+=x sum x 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 scan = new Scanner(System.in);
		int n =scan.nextInt();
		int a[]=new int[n+1];
		int b[]=new int[n];
		for(int i=0;i<n+1;i++) {
			a[i]=scan.nextInt();
		}
		for(int i=0;i<n;i++) {
			b[i]=scan.nextInt();
		}
		scan.close();

		long sum=0;
		for(int i=0;i<n;i++) {
			int x=Math.min(b[i],a[i]);
			sum+=x;
			x=Math.min(b[i]-x,a[i+1]);
			a[i+1]-=x;
			sum+=x;
		}
		System.out.println(sum);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n =scan.nextInt();
		int a[]=new int[n+1];
		int b[]=new int[n];
		for(int i=0;i<n+1;i++) {
			a[i]=scan.nextInt();
		}
		for(int i=0;i<n;i++) {
			b[i]=scan.nextInt();
		}
		scan.close();

		long sum=0;
		for(int i=0;i<n;i++) {
			int x=Math.min(b[i],a[i]);
			sum+=x;
			x=Math.min(b[i]-x,a[i+1]);
			a[i+1]-=x;
			sum+=x;
		}
		System.out.println(sum);
	}
} Main
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n =scan.nextInt();
		int a[]=new int[n+1];
		int b[]=new int[n];
		for(int i=0;i<n+1;i++) {
			a[i]=scan.nextInt();
		}
		for(int i=0;i<n;i++) {
			b[i]=scan.nextInt();
		}
		scan.close();

		long sum=0;
		for(int i=0;i<n;i++) {
			int x=Math.min(b[i],a[i]);
			sum+=x;
			x=Math.min(b[i]-x,a[i+1]);
			a[i+1]-=x;
			sum+=x;
		}
		System.out.println(sum);
	}
}
