import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	    Scanner scanner = new Scanner(System.in);

	    int N = Integer.parseInt(scanner.next());
	    long[] A  = new long[N+1];
	    long[] B  = new long[N];
	    
	    for (int i=0; i<N+1; i++) {
	    	A[i]=Long.parseLong(scanner.next());
	    }
	    for (int i=0; i<N; i++) {
	    	B[i]=Long.parseLong(scanner.next());
	    }
	    
	    long max=0;
	    for (int i=0; i<N; i++) {
	        long b = B[N-i-1];
	        long a1 = A[N-i];
	        long a2 = A[N-i-1];
	        if (a1 >= b) {
	        	max+=b;
	        } else {
	        	max += a1;
	        	b-=a1;
	        	if (a2>=b) {
	        		max+=b;
	        		A[N-i-1] -=b;
	        	} else {
	        		max+=a2;
	        		A[N-i-1] =0;
	        	}
	        }
	    }
        System.out.print(max);
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
	    Scanner scanner = new Scanner(System.in);

	    int N = Integer.parseInt(scanner.next());
	    long[] A  = new long[N+1];
	    long[] B  = new long[N];
	    
	    for (int i=0; i<N+1; i++) {
	    	A[i]=Long.parseLong(scanner.next());
	    }
	    for (int i=0; i<N; i++) {
	    	B[i]=Long.parseLong(scanner.next());
	    }
	    
	    long max=0;
	    for (int i=0; i<N; i++) {
	        long b = B[N-i-1];
	        long a1 = A[N-i];
	        long a2 = A[N-i-1];
	        if (a1 >= b) {
	        	max+=b;
	        } else {
	        	max += a1;
	        	b-=a1;
	        	if (a2>=b) {
	        		max+=b;
	        		A[N-i-1] -=b;
	        	} else {
	        		max+=a2;
	        		A[N-i-1] =0;
	        	}
	        }
	    }
        System.out.print(max);
	}

} Main public static void main(String[] args) {
	    Scanner scanner = new Scanner(System.in);

	    int N = Integer.parseInt(scanner.next());
	    long[] A  = new long[N+1];
	    long[] B  = new long[N];
	    
	    for (int i=0; i<N+1; i++) {
	    	A[i]=Long.parseLong(scanner.next());
	    }
	    for (int i=0; i<N; i++) {
	    	B[i]=Long.parseLong(scanner.next());
	    }
	    
	    long max=0;
	    for (int i=0; i<N; i++) {
	        long b = B[N-i-1];
	        long a1 = A[N-i];
	        long a2 = A[N-i-1];
	        if (a1 >= b) {
	        	max+=b;
	        } else {
	        	max += a1;
	        	b-=a1;
	        	if (a2>=b) {
	        		max+=b;
	        		A[N-i-1] -=b;
	        	} else {
	        		max+=a2;
	        		A[N-i-1] =0;
	        	}
	        }
	    }
        System.out.print(max);
	} main {
	    Scanner scanner = new Scanner(System.in);

	    int N = Integer.parseInt(scanner.next());
	    long[] A  = new long[N+1];
	    long[] B  = new long[N];
	    
	    for (int i=0; i<N+1; i++) {
	    	A[i]=Long.parseLong(scanner.next());
	    }
	    for (int i=0; i<N; i++) {
	    	B[i]=Long.parseLong(scanner.next());
	    }
	    
	    long max=0;
	    for (int i=0; i<N; i++) {
	        long b = B[N-i-1];
	        long a1 = A[N-i];
	        long a2 = A[N-i-1];
	        if (a1 >= b) {
	        	max+=b;
	        } else {
	        	max += a1;
	        	b-=a1;
	        	if (a2>=b) {
	        		max+=b;
	        		A[N-i-1] -=b;
	        	} else {
	        		max+=a2;
	        		A[N-i-1] =0;
	        	}
	        }
	    }
        System.out.print(max);
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = Integer.parseInt(scanner.next()); N Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner 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]=Long.parseLong(scanner.next());
	    } int i=0; int i=0; i 0 i<N+1 i N+1 N 1 i++ i++ i {
	    	A[i]=Long.parseLong(scanner.next());
	    } {
	    	A[i]=Long.parseLong(scanner.next());
	    } A[i]=Long.parseLong(scanner.next()) A[i] A i Long.parseLong(scanner.next()) Long.parseLong Long scanner.next() scanner.next scanner for (int i=0; i<N; i++) {
	    	B[i]=Long.parseLong(scanner.next());
	    } int i=0; int i=0; i 0 i<N i N i++ i++ i {
	    	B[i]=Long.parseLong(scanner.next());
	    } {
	    	B[i]=Long.parseLong(scanner.next());
	    } B[i]=Long.parseLong(scanner.next()) B[i] B i Long.parseLong(scanner.next()) Long.parseLong Long scanner.next() scanner.next scanner long max=0; max 0 for (int i=0; i<N; i++) {
	        long b = B[N-i-1];
	        long a1 = A[N-i];
	        long a2 = A[N-i-1];
	        if (a1 >= b) {
	        	max+=b;
	        } else {
	        	max += a1;
	        	b-=a1;
	        	if (a2>=b) {
	        		max+=b;
	        		A[N-i-1] -=b;
	        	} else {
	        		max+=a2;
	        		A[N-i-1] =0;
	        	}
	        }
	    } int i=0; int i=0; i 0 i<N i N i++ i++ i {
	        long b = B[N-i-1];
	        long a1 = A[N-i];
	        long a2 = A[N-i-1];
	        if (a1 >= b) {
	        	max+=b;
	        } else {
	        	max += a1;
	        	b-=a1;
	        	if (a2>=b) {
	        		max+=b;
	        		A[N-i-1] -=b;
	        	} else {
	        		max+=a2;
	        		A[N-i-1] =0;
	        	}
	        }
	    } {
	        long b = B[N-i-1];
	        long a1 = A[N-i];
	        long a2 = A[N-i-1];
	        if (a1 >= b) {
	        	max+=b;
	        } else {
	        	max += a1;
	        	b-=a1;
	        	if (a2>=b) {
	        		max+=b;
	        		A[N-i-1] -=b;
	        	} else {
	        		max+=a2;
	        		A[N-i-1] =0;
	        	}
	        }
	    } long b = B[N-i-1]; b B[N-i-1] B N-i-1 N-i-1 N i 1 long a1 = A[N-i]; a1 A[N-i] A N-i N i long a2 = A[N-i-1]; a2 A[N-i-1] A N-i-1 N-i-1 N i 1 if (a1 >= b) {
	        	max+=b;
	        } else {
	        	max += a1;
	        	b-=a1;
	        	if (a2>=b) {
	        		max+=b;
	        		A[N-i-1] -=b;
	        	} else {
	        		max+=a2;
	        		A[N-i-1] =0;
	        	}
	        } a1 >= b a1 b {
	        	max+=b;
	        } max+=b max b {
	        	max += a1;
	        	b-=a1;
	        	if (a2>=b) {
	        		max+=b;
	        		A[N-i-1] -=b;
	        	} else {
	        		max+=a2;
	        		A[N-i-1] =0;
	        	}
	        } max += a1 max a1 b-=a1 b a1 if (a2>=b) {
	        		max+=b;
	        		A[N-i-1] -=b;
	        	} else {
	        		max+=a2;
	        		A[N-i-1] =0;
	        	} a2>=b a2 b {
	        		max+=b;
	        		A[N-i-1] -=b;
	        	} max+=b max b A[N-i-1] -=b A[N-i-1] A N-i-1 N-i-1 N i 1 b {
	        		max+=a2;
	        		A[N-i-1] =0;
	        	} max+=a2 max a2 A[N-i-1] =0 A[N-i-1] A N-i-1 N-i-1 N i 1 0 System.out.print(max) System.out.print System.out System System.out max String[] args args public class Main {

	public static void main(String[] args) {
	    Scanner scanner = new Scanner(System.in);

	    int N = Integer.parseInt(scanner.next());
	    long[] A  = new long[N+1];
	    long[] B  = new long[N];
	    
	    for (int i=0; i<N+1; i++) {
	    	A[i]=Long.parseLong(scanner.next());
	    }
	    for (int i=0; i<N; i++) {
	    	B[i]=Long.parseLong(scanner.next());
	    }
	    
	    long max=0;
	    for (int i=0; i<N; i++) {
	        long b = B[N-i-1];
	        long a1 = A[N-i];
	        long a2 = A[N-i-1];
	        if (a1 >= b) {
	        	max+=b;
	        } else {
	        	max += a1;
	        	b-=a1;
	        	if (a2>=b) {
	        		max+=b;
	        		A[N-i-1] -=b;
	        	} else {
	        		max+=a2;
	        		A[N-i-1] =0;
	        	}
	        }
	    }
        System.out.print(max);
	}

} public class Main {

	public static void main(String[] args) {
	    Scanner scanner = new Scanner(System.in);

	    int N = Integer.parseInt(scanner.next());
	    long[] A  = new long[N+1];
	    long[] B  = new long[N];
	    
	    for (int i=0; i<N+1; i++) {
	    	A[i]=Long.parseLong(scanner.next());
	    }
	    for (int i=0; i<N; i++) {
	    	B[i]=Long.parseLong(scanner.next());
	    }
	    
	    long max=0;
	    for (int i=0; i<N; i++) {
	        long b = B[N-i-1];
	        long a1 = A[N-i];
	        long a2 = A[N-i-1];
	        if (a1 >= b) {
	        	max+=b;
	        } else {
	        	max += a1;
	        	b-=a1;
	        	if (a2>=b) {
	        		max+=b;
	        		A[N-i-1] -=b;
	        	} else {
	        		max+=a2;
	        		A[N-i-1] =0;
	        	}
	        }
	    }
        System.out.print(max);
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	    Scanner scanner = new Scanner(System.in);

	    int N = Integer.parseInt(scanner.next());
	    long[] A  = new long[N+1];
	    long[] B  = new long[N];
	    
	    for (int i=0; i<N+1; i++) {
	    	A[i]=Long.parseLong(scanner.next());
	    }
	    for (int i=0; i<N; i++) {
	    	B[i]=Long.parseLong(scanner.next());
	    }
	    
	    long max=0;
	    for (int i=0; i<N; i++) {
	        long b = B[N-i-1];
	        long a1 = A[N-i];
	        long a2 = A[N-i-1];
	        if (a1 >= b) {
	        	max+=b;
	        } else {
	        	max += a1;
	        	b-=a1;
	        	if (a2>=b) {
	        		max+=b;
	        		A[N-i-1] -=b;
	        	} else {
	        		max+=a2;
	        		A[N-i-1] =0;
	        	}
	        }
	    }
        System.out.print(max);
	}

}