import java.util.Scanner;

public class Main {

	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
		int[] a = new int[n+1];
		int[] b = new int[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 z = 0;
		for (int j=0; j<n; j++) {
			int x = Math.min(a[j], b[j]);
			z += x;
			a[j] -=x;
			b[j] -=x;
			
			int y = Math.min(a[j+1], b[j]);
			z += y;
			a[j+1] -=y;
			b[j] -=y;
			
		}
		
		System.out.println(z);

	}

} 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();
		int[] a = new int[n+1];
		int[] b = new int[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 z = 0;
		for (int j=0; j<n; j++) {
			int x = Math.min(a[j], b[j]);
			z += x;
			a[j] -=x;
			b[j] -=x;
			
			int y = Math.min(a[j+1], b[j]);
			z += y;
			a[j+1] -=y;
			b[j] -=y;
			
		}
		
		System.out.println(z);

	}

} Main public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
		int[] a = new int[n+1];
		int[] b = new int[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 z = 0;
		for (int j=0; j<n; j++) {
			int x = Math.min(a[j], b[j]);
			z += x;
			a[j] -=x;
			b[j] -=x;
			
			int y = Math.min(a[j+1], b[j]);
			z += y;
			a[j+1] -=y;
			b[j] -=y;
			
		}
		
		System.out.println(z);

	} main {
		
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
		int[] a = new int[n+1];
		int[] b = new int[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 z = 0;
		for (int j=0; j<n; j++) {
			int x = Math.min(a[j], b[j]);
			z += x;
			a[j] -=x;
			b[j] -=x;
			
			int y = Math.min(a[j+1], b[j]);
			z += y;
			a[j+1] -=y;
			b[j] -=y;
			
		}
		
		System.out.println(z);

	} 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 int[] b = new int[n]; b new int[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 z = 0; z 0 for (int j=0; j<n; j++) {
			int x = Math.min(a[j], b[j]);
			z += x;
			a[j] -=x;
			b[j] -=x;
			
			int y = Math.min(a[j+1], b[j]);
			z += y;
			a[j+1] -=y;
			b[j] -=y;
			
		} int j=0; int j=0; j 0 j<n j n j++ j++ j {
			int x = Math.min(a[j], b[j]);
			z += x;
			a[j] -=x;
			b[j] -=x;
			
			int y = Math.min(a[j+1], b[j]);
			z += y;
			a[j+1] -=y;
			b[j] -=y;
			
		} {
			int x = Math.min(a[j], b[j]);
			z += x;
			a[j] -=x;
			b[j] -=x;
			
			int y = Math.min(a[j+1], b[j]);
			z += y;
			a[j+1] -=y;
			b[j] -=y;
			
		} int x = Math.min(a[j], b[j]); x Math.min(a[j], b[j]) Math.min Math a[j] a j b[j] b j z += x z x a[j] -=x a[j] a j x b[j] -=x b[j] b j x int y = Math.min(a[j+1], b[j]); y Math.min(a[j+1], b[j]) Math.min Math a[j+1] a j+1 j 1 b[j] b j z += y z y a[j+1] -=y a[j+1] a j+1 j 1 y b[j] -=y b[j] b j y System.out.println(z) System.out.println System.out System System.out z String[] args args public class Main {

	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
		int[] a = new int[n+1];
		int[] b = new int[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 z = 0;
		for (int j=0; j<n; j++) {
			int x = Math.min(a[j], b[j]);
			z += x;
			a[j] -=x;
			b[j] -=x;
			
			int y = Math.min(a[j+1], b[j]);
			z += y;
			a[j+1] -=y;
			b[j] -=y;
			
		}
		
		System.out.println(z);

	}

} public class Main {

	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
		int[] a = new int[n+1];
		int[] b = new int[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 z = 0;
		for (int j=0; j<n; j++) {
			int x = Math.min(a[j], b[j]);
			z += x;
			a[j] -=x;
			b[j] -=x;
			
			int y = Math.min(a[j+1], b[j]);
			z += y;
			a[j+1] -=y;
			b[j] -=y;
			
		}
		
		System.out.println(z);

	}

} Main
import java.util.Scanner;

public class Main {

	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
		int[] a = new int[n+1];
		int[] b = new int[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 z = 0;
		for (int j=0; j<n; j++) {
			int x = Math.min(a[j], b[j]);
			z += x;
			a[j] -=x;
			b[j] -=x;
			
			int y = Math.min(a[j+1], b[j]);
			z += y;
			a[j+1] -=y;
			b[j] -=y;
			
		}
		
		System.out.println(z);

	}

}
