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];
		    long[] b = new long[n];
		    for(int i=0; i<n+1; i++) {
		    	a[i] = sc.nextInt();
		    }
		    for(int i=0; i<n; i++) {
		    	b[i] = sc.nextInt();
		    }

		    long monster =0;
		    for(int i=n-1; i>=0; i--) {
		    	if(b[i]-a[i+1]>=0) {
		    		monster += a[i+1];
		    		b[i] = b[i]-a[i+1];
		    		if(b[i]-a[i]>=0) {
		    			monster +=a[i];
		    			a[i] = 0;
		    		}else {
		    			monster += b[i];
		    			a[i] = a[i]-b[i];
		    		}
		    	}else {
		    		monster += b[i];
		    	}
		    }

		    System.out.println(monster);
	}
} 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];
		    long[] b = new long[n];
		    for(int i=0; i<n+1; i++) {
		    	a[i] = sc.nextInt();
		    }
		    for(int i=0; i<n; i++) {
		    	b[i] = sc.nextInt();
		    }

		    long monster =0;
		    for(int i=n-1; i>=0; i--) {
		    	if(b[i]-a[i+1]>=0) {
		    		monster += a[i+1];
		    		b[i] = b[i]-a[i+1];
		    		if(b[i]-a[i]>=0) {
		    			monster +=a[i];
		    			a[i] = 0;
		    		}else {
		    			monster += b[i];
		    			a[i] = a[i]-b[i];
		    		}
		    	}else {
		    		monster += b[i];
		    	}
		    }

		    System.out.println(monster);
	}
} Main public static void main(String[] args) {
		    Scanner sc = new Scanner(System.in);
		    int n = sc.nextInt();
		    long[] a = new long[n+1];
		    long[] b = new long[n];
		    for(int i=0; i<n+1; i++) {
		    	a[i] = sc.nextInt();
		    }
		    for(int i=0; i<n; i++) {
		    	b[i] = sc.nextInt();
		    }

		    long monster =0;
		    for(int i=n-1; i>=0; i--) {
		    	if(b[i]-a[i+1]>=0) {
		    		monster += a[i+1];
		    		b[i] = b[i]-a[i+1];
		    		if(b[i]-a[i]>=0) {
		    			monster +=a[i];
		    			a[i] = 0;
		    		}else {
		    			monster += b[i];
		    			a[i] = a[i]-b[i];
		    		}
		    	}else {
		    		monster += b[i];
		    	}
		    }

		    System.out.println(monster);
	} main {
		    Scanner sc = new Scanner(System.in);
		    int n = sc.nextInt();
		    long[] a = new long[n+1];
		    long[] b = new long[n];
		    for(int i=0; i<n+1; i++) {
		    	a[i] = sc.nextInt();
		    }
		    for(int i=0; i<n; i++) {
		    	b[i] = sc.nextInt();
		    }

		    long monster =0;
		    for(int i=n-1; i>=0; i--) {
		    	if(b[i]-a[i+1]>=0) {
		    		monster += a[i+1];
		    		b[i] = b[i]-a[i+1];
		    		if(b[i]-a[i]>=0) {
		    			monster +=a[i];
		    			a[i] = 0;
		    		}else {
		    			monster += b[i];
		    			a[i] = a[i]-b[i];
		    		}
		    	}else {
		    		monster += b[i];
		    	}
		    }

		    System.out.println(monster);
	} 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 long[] b = new long[n]; b new long[n] n for(int i=0; i<n+1; i++) {
		    	a[i] = sc.nextInt();
		    } int i=0; int i=0; i 0 i<n+1 i n+1 n 1 i++ i++ i {
		    	a[i] = sc.nextInt();
		    } {
		    	a[i] = sc.nextInt();
		    } a[i] = sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc 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 long monster =0; monster 0 for(int i=n-1; i>=0; i--) {
		    	if(b[i]-a[i+1]>=0) {
		    		monster += a[i+1];
		    		b[i] = b[i]-a[i+1];
		    		if(b[i]-a[i]>=0) {
		    			monster +=a[i];
		    			a[i] = 0;
		    		}else {
		    			monster += b[i];
		    			a[i] = a[i]-b[i];
		    		}
		    	}else {
		    		monster += b[i];
		    	}
		    } int i=n-1; int i=n-1; i n-1 n 1 i>=0 i 0 i-- i-- i {
		    	if(b[i]-a[i+1]>=0) {
		    		monster += a[i+1];
		    		b[i] = b[i]-a[i+1];
		    		if(b[i]-a[i]>=0) {
		    			monster +=a[i];
		    			a[i] = 0;
		    		}else {
		    			monster += b[i];
		    			a[i] = a[i]-b[i];
		    		}
		    	}else {
		    		monster += b[i];
		    	}
		    } {
		    	if(b[i]-a[i+1]>=0) {
		    		monster += a[i+1];
		    		b[i] = b[i]-a[i+1];
		    		if(b[i]-a[i]>=0) {
		    			monster +=a[i];
		    			a[i] = 0;
		    		}else {
		    			monster += b[i];
		    			a[i] = a[i]-b[i];
		    		}
		    	}else {
		    		monster += b[i];
		    	}
		    } if(b[i]-a[i+1]>=0) {
		    		monster += a[i+1];
		    		b[i] = b[i]-a[i+1];
		    		if(b[i]-a[i]>=0) {
		    			monster +=a[i];
		    			a[i] = 0;
		    		}else {
		    			monster += b[i];
		    			a[i] = a[i]-b[i];
		    		}
		    	}else {
		    		monster += b[i];
		    	} b[i]-a[i+1]>=0 b[i]-a[i+1] b[i] b i a[i+1] a i+1 i 1 0 {
		    		monster += a[i+1];
		    		b[i] = b[i]-a[i+1];
		    		if(b[i]-a[i]>=0) {
		    			monster +=a[i];
		    			a[i] = 0;
		    		}else {
		    			monster += b[i];
		    			a[i] = a[i]-b[i];
		    		}
		    	} monster += a[i+1] monster a[i+1] a i+1 i 1 b[i] = b[i]-a[i+1] b[i] b i b[i]-a[i+1] b[i] b i a[i+1] a i+1 i 1 if(b[i]-a[i]>=0) {
		    			monster +=a[i];
		    			a[i] = 0;
		    		}else {
		    			monster += b[i];
		    			a[i] = a[i]-b[i];
		    		} b[i]-a[i]>=0 b[i]-a[i] b[i] b i a[i] a i 0 {
		    			monster +=a[i];
		    			a[i] = 0;
		    		} monster +=a[i] monster a[i] a i a[i] = 0 a[i] a i 0 {
		    			monster += b[i];
		    			a[i] = a[i]-b[i];
		    		} monster += b[i] monster b[i] b i a[i] = a[i]-b[i] a[i] a i a[i]-b[i] a[i] a i b[i] b i {
		    		monster += b[i];
		    	} monster += b[i] monster b[i] b i System.out.println(monster) System.out.println System.out System System.out monster 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];
		    long[] b = new long[n];
		    for(int i=0; i<n+1; i++) {
		    	a[i] = sc.nextInt();
		    }
		    for(int i=0; i<n; i++) {
		    	b[i] = sc.nextInt();
		    }

		    long monster =0;
		    for(int i=n-1; i>=0; i--) {
		    	if(b[i]-a[i+1]>=0) {
		    		monster += a[i+1];
		    		b[i] = b[i]-a[i+1];
		    		if(b[i]-a[i]>=0) {
		    			monster +=a[i];
		    			a[i] = 0;
		    		}else {
		    			monster += b[i];
		    			a[i] = a[i]-b[i];
		    		}
		    	}else {
		    		monster += b[i];
		    	}
		    }

		    System.out.println(monster);
	}
} 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];
		    long[] b = new long[n];
		    for(int i=0; i<n+1; i++) {
		    	a[i] = sc.nextInt();
		    }
		    for(int i=0; i<n; i++) {
		    	b[i] = sc.nextInt();
		    }

		    long monster =0;
		    for(int i=n-1; i>=0; i--) {
		    	if(b[i]-a[i+1]>=0) {
		    		monster += a[i+1];
		    		b[i] = b[i]-a[i+1];
		    		if(b[i]-a[i]>=0) {
		    			monster +=a[i];
		    			a[i] = 0;
		    		}else {
		    			monster += b[i];
		    			a[i] = a[i]-b[i];
		    		}
		    	}else {
		    		monster += b[i];
		    	}
		    }

		    System.out.println(monster);
	}
} 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];
		    long[] b = new long[n];
		    for(int i=0; i<n+1; i++) {
		    	a[i] = sc.nextInt();
		    }
		    for(int i=0; i<n; i++) {
		    	b[i] = sc.nextInt();
		    }

		    long monster =0;
		    for(int i=n-1; i>=0; i--) {
		    	if(b[i]-a[i+1]>=0) {
		    		monster += a[i+1];
		    		b[i] = b[i]-a[i+1];
		    		if(b[i]-a[i]>=0) {
		    			monster +=a[i];
		    			a[i] = 0;
		    		}else {
		    			monster += b[i];
		    			a[i] = a[i]-b[i];
		    		}
		    	}else {
		    		monster += b[i];
		    	}
		    }

		    System.out.println(monster);
	}
}
