import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] As = new int[N+1];
		for(int i=0; i<=N; i++) {
			As[i] = Integer.parseInt(sc.next());
		}
		long last = 0;
		long monsters = 0;
		for(int i=0; i<N; i++) {
			long ability = Integer.parseInt(sc.next());
			if(As[i] >= ability + last) {
				monsters += (ability+ last);
				last = 0;
			}else {
				monsters += As[i];
				if(last >= As[i]) {
					last = ability;
				}else {
					last = ability + last - As[i];	
				}
			}
		}
		sc.close();
		if(As[N] >=  last) {
			monsters +=  last;
		}else {
			monsters += As[N];
		}
		System.out.println(monsters);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] As = new int[N+1];
		for(int i=0; i<=N; i++) {
			As[i] = Integer.parseInt(sc.next());
		}
		long last = 0;
		long monsters = 0;
		for(int i=0; i<N; i++) {
			long ability = Integer.parseInt(sc.next());
			if(As[i] >= ability + last) {
				monsters += (ability+ last);
				last = 0;
			}else {
				monsters += As[i];
				if(last >= As[i]) {
					last = ability;
				}else {
					last = ability + last - As[i];	
				}
			}
		}
		sc.close();
		if(As[N] >=  last) {
			monsters +=  last;
		}else {
			monsters += As[N];
		}
		System.out.println(monsters);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] As = new int[N+1];
		for(int i=0; i<=N; i++) {
			As[i] = Integer.parseInt(sc.next());
		}
		long last = 0;
		long monsters = 0;
		for(int i=0; i<N; i++) {
			long ability = Integer.parseInt(sc.next());
			if(As[i] >= ability + last) {
				monsters += (ability+ last);
				last = 0;
			}else {
				monsters += As[i];
				if(last >= As[i]) {
					last = ability;
				}else {
					last = ability + last - As[i];	
				}
			}
		}
		sc.close();
		if(As[N] >=  last) {
			monsters +=  last;
		}else {
			monsters += As[N];
		}
		System.out.println(monsters);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] As = new int[N+1];
		for(int i=0; i<=N; i++) {
			As[i] = Integer.parseInt(sc.next());
		}
		long last = 0;
		long monsters = 0;
		for(int i=0; i<N; i++) {
			long ability = Integer.parseInt(sc.next());
			if(As[i] >= ability + last) {
				monsters += (ability+ last);
				last = 0;
			}else {
				monsters += As[i];
				if(last >= As[i]) {
					last = ability;
				}else {
					last = ability + last - As[i];	
				}
			}
		}
		sc.close();
		if(As[N] >=  last) {
			monsters +=  last;
		}else {
			monsters += As[N];
		}
		System.out.println(monsters);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] As = new int[N+1]; As new int[N+1] N+1 N 1 for(int i=0; i<=N; i++) {
			As[i] = Integer.parseInt(sc.next());
		} int i=0; int i=0; i 0 i<=N i N i++ i++ i {
			As[i] = Integer.parseInt(sc.next());
		} {
			As[i] = Integer.parseInt(sc.next());
		} As[i] = Integer.parseInt(sc.next()) As[i] As i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc long last = 0; last 0 long monsters = 0; monsters 0 for(int i=0; i<N; i++) {
			long ability = Integer.parseInt(sc.next());
			if(As[i] >= ability + last) {
				monsters += (ability+ last);
				last = 0;
			}else {
				monsters += As[i];
				if(last >= As[i]) {
					last = ability;
				}else {
					last = ability + last - As[i];	
				}
			}
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			long ability = Integer.parseInt(sc.next());
			if(As[i] >= ability + last) {
				monsters += (ability+ last);
				last = 0;
			}else {
				monsters += As[i];
				if(last >= As[i]) {
					last = ability;
				}else {
					last = ability + last - As[i];	
				}
			}
		} {
			long ability = Integer.parseInt(sc.next());
			if(As[i] >= ability + last) {
				monsters += (ability+ last);
				last = 0;
			}else {
				monsters += As[i];
				if(last >= As[i]) {
					last = ability;
				}else {
					last = ability + last - As[i];	
				}
			}
		} long ability = Integer.parseInt(sc.next()); ability Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc if(As[i] >= ability + last) {
				monsters += (ability+ last);
				last = 0;
			}else {
				monsters += As[i];
				if(last >= As[i]) {
					last = ability;
				}else {
					last = ability + last - As[i];	
				}
			} As[i] >= ability + last As[i] As i ability + last ability last {
				monsters += (ability+ last);
				last = 0;
			} monsters += (ability+ last) monsters (ability+ last) ability last last = 0 last 0 {
				monsters += As[i];
				if(last >= As[i]) {
					last = ability;
				}else {
					last = ability + last - As[i];	
				}
			} monsters += As[i] monsters As[i] As i if(last >= As[i]) {
					last = ability;
				}else {
					last = ability + last - As[i];	
				} last >= As[i] last As[i] As i {
					last = ability;
				} last = ability last ability {
					last = ability + last - As[i];	
				} last = ability + last - As[i] last ability + last - As[i] ability + last ability last As[i] As i sc.close() sc.close sc if(As[N] >=  last) {
			monsters +=  last;
		}else {
			monsters += As[N];
		} As[N] >=  last As[N] As N last {
			monsters +=  last;
		} monsters +=  last monsters last {
			monsters += As[N];
		} monsters += As[N] monsters As[N] As N System.out.println(monsters) System.out.println System.out System System.out monsters String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] As = new int[N+1];
		for(int i=0; i<=N; i++) {
			As[i] = Integer.parseInt(sc.next());
		}
		long last = 0;
		long monsters = 0;
		for(int i=0; i<N; i++) {
			long ability = Integer.parseInt(sc.next());
			if(As[i] >= ability + last) {
				monsters += (ability+ last);
				last = 0;
			}else {
				monsters += As[i];
				if(last >= As[i]) {
					last = ability;
				}else {
					last = ability + last - As[i];	
				}
			}
		}
		sc.close();
		if(As[N] >=  last) {
			monsters +=  last;
		}else {
			monsters += As[N];
		}
		System.out.println(monsters);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] As = new int[N+1];
		for(int i=0; i<=N; i++) {
			As[i] = Integer.parseInt(sc.next());
		}
		long last = 0;
		long monsters = 0;
		for(int i=0; i<N; i++) {
			long ability = Integer.parseInt(sc.next());
			if(As[i] >= ability + last) {
				monsters += (ability+ last);
				last = 0;
			}else {
				monsters += As[i];
				if(last >= As[i]) {
					last = ability;
				}else {
					last = ability + last - As[i];	
				}
			}
		}
		sc.close();
		if(As[N] >=  last) {
			monsters +=  last;
		}else {
			monsters += As[N];
		}
		System.out.println(monsters);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] As = new int[N+1];
		for(int i=0; i<=N; i++) {
			As[i] = Integer.parseInt(sc.next());
		}
		long last = 0;
		long monsters = 0;
		for(int i=0; i<N; i++) {
			long ability = Integer.parseInt(sc.next());
			if(As[i] >= ability + last) {
				monsters += (ability+ last);
				last = 0;
			}else {
				monsters += As[i];
				if(last >= As[i]) {
					last = ability;
				}else {
					last = ability + last - As[i];	
				}
			}
		}
		sc.close();
		if(As[N] >=  last) {
			monsters +=  last;
		}else {
			monsters += As[N];
		}
		System.out.println(monsters);
	}
}