import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	long[] Ai = new long[N+1];
    	for (int i = 0; i < Ai.length; i++) {
    		Ai[i] = sc.nextLong();
    	}
    	long tmp = 0L;
    	long hunt = 0L;
    	for (int i = 0; i < N; i++) {
    		long B = sc.nextLong();
    		long Btmp = B + tmp;
    		if (Ai[i] <= B + tmp) {
    			if (Ai[i] <= tmp) {
    				tmp = B;
    			} else {
    				tmp = B + tmp - Ai[i];
    			}
    			hunt += Ai[i];
    		} else {
    			tmp = 0L;
    			hunt += Btmp;
    		}
    	}
    	if (Ai[N] <= tmp) {
    		hunt += Ai[N];
    	} else {
    		hunt += tmp;
    	}
    	System.out.println(hunt);
    }
} import java.util.*; util.* java public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	long[] Ai = new long[N+1];
    	for (int i = 0; i < Ai.length; i++) {
    		Ai[i] = sc.nextLong();
    	}
    	long tmp = 0L;
    	long hunt = 0L;
    	for (int i = 0; i < N; i++) {
    		long B = sc.nextLong();
    		long Btmp = B + tmp;
    		if (Ai[i] <= B + tmp) {
    			if (Ai[i] <= tmp) {
    				tmp = B;
    			} else {
    				tmp = B + tmp - Ai[i];
    			}
    			hunt += Ai[i];
    		} else {
    			tmp = 0L;
    			hunt += Btmp;
    		}
    	}
    	if (Ai[N] <= tmp) {
    		hunt += Ai[N];
    	} else {
    		hunt += tmp;
    	}
    	System.out.println(hunt);
    }
} Main public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	long[] Ai = new long[N+1];
    	for (int i = 0; i < Ai.length; i++) {
    		Ai[i] = sc.nextLong();
    	}
    	long tmp = 0L;
    	long hunt = 0L;
    	for (int i = 0; i < N; i++) {
    		long B = sc.nextLong();
    		long Btmp = B + tmp;
    		if (Ai[i] <= B + tmp) {
    			if (Ai[i] <= tmp) {
    				tmp = B;
    			} else {
    				tmp = B + tmp - Ai[i];
    			}
    			hunt += Ai[i];
    		} else {
    			tmp = 0L;
    			hunt += Btmp;
    		}
    	}
    	if (Ai[N] <= tmp) {
    		hunt += Ai[N];
    	} else {
    		hunt += tmp;
    	}
    	System.out.println(hunt);
    } main {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	long[] Ai = new long[N+1];
    	for (int i = 0; i < Ai.length; i++) {
    		Ai[i] = sc.nextLong();
    	}
    	long tmp = 0L;
    	long hunt = 0L;
    	for (int i = 0; i < N; i++) {
    		long B = sc.nextLong();
    		long Btmp = B + tmp;
    		if (Ai[i] <= B + tmp) {
    			if (Ai[i] <= tmp) {
    				tmp = B;
    			} else {
    				tmp = B + tmp - Ai[i];
    			}
    			hunt += Ai[i];
    		} else {
    			tmp = 0L;
    			hunt += Btmp;
    		}
    	}
    	if (Ai[N] <= tmp) {
    		hunt += Ai[N];
    	} else {
    		hunt += tmp;
    	}
    	System.out.println(hunt);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc long[] Ai = new long[N+1]; Ai new long[N+1] N+1 N 1 for (int i = 0; i < Ai.length; i++) {
    		Ai[i] = sc.nextLong();
    	} int i = 0; int i = 0; i 0 i < Ai.length i Ai.length Ai Ai.length i++ i++ i {
    		Ai[i] = sc.nextLong();
    	} {
    		Ai[i] = sc.nextLong();
    	} Ai[i] = sc.nextLong() Ai[i] Ai i sc.nextLong() sc.nextLong sc long tmp = 0L; tmp 0L long hunt = 0L; hunt 0L for (int i = 0; i < N; i++) {
    		long B = sc.nextLong();
    		long Btmp = B + tmp;
    		if (Ai[i] <= B + tmp) {
    			if (Ai[i] <= tmp) {
    				tmp = B;
    			} else {
    				tmp = B + tmp - Ai[i];
    			}
    			hunt += Ai[i];
    		} else {
    			tmp = 0L;
    			hunt += Btmp;
    		}
    	} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
    		long B = sc.nextLong();
    		long Btmp = B + tmp;
    		if (Ai[i] <= B + tmp) {
    			if (Ai[i] <= tmp) {
    				tmp = B;
    			} else {
    				tmp = B + tmp - Ai[i];
    			}
    			hunt += Ai[i];
    		} else {
    			tmp = 0L;
    			hunt += Btmp;
    		}
    	} {
    		long B = sc.nextLong();
    		long Btmp = B + tmp;
    		if (Ai[i] <= B + tmp) {
    			if (Ai[i] <= tmp) {
    				tmp = B;
    			} else {
    				tmp = B + tmp - Ai[i];
    			}
    			hunt += Ai[i];
    		} else {
    			tmp = 0L;
    			hunt += Btmp;
    		}
    	} long B = sc.nextLong(); B sc.nextLong() sc.nextLong sc long Btmp = B + tmp; Btmp B + tmp B tmp if (Ai[i] <= B + tmp) {
    			if (Ai[i] <= tmp) {
    				tmp = B;
    			} else {
    				tmp = B + tmp - Ai[i];
    			}
    			hunt += Ai[i];
    		} else {
    			tmp = 0L;
    			hunt += Btmp;
    		} Ai[i] <= B + tmp Ai[i] Ai i B + tmp B tmp {
    			if (Ai[i] <= tmp) {
    				tmp = B;
    			} else {
    				tmp = B + tmp - Ai[i];
    			}
    			hunt += Ai[i];
    		} if (Ai[i] <= tmp) {
    				tmp = B;
    			} else {
    				tmp = B + tmp - Ai[i];
    			} Ai[i] <= tmp Ai[i] Ai i tmp {
    				tmp = B;
    			} tmp = B tmp B {
    				tmp = B + tmp - Ai[i];
    			} tmp = B + tmp - Ai[i] tmp B + tmp - Ai[i] B + tmp B tmp Ai[i] Ai i hunt += Ai[i] hunt Ai[i] Ai i {
    			tmp = 0L;
    			hunt += Btmp;
    		} tmp = 0L tmp 0L hunt += Btmp hunt Btmp if (Ai[N] <= tmp) {
    		hunt += Ai[N];
    	} else {
    		hunt += tmp;
    	} Ai[N] <= tmp Ai[N] Ai N tmp {
    		hunt += Ai[N];
    	} hunt += Ai[N] hunt Ai[N] Ai N {
    		hunt += tmp;
    	} hunt += tmp hunt tmp System.out.println(hunt) System.out.println System.out System System.out hunt String[] args args public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	long[] Ai = new long[N+1];
    	for (int i = 0; i < Ai.length; i++) {
    		Ai[i] = sc.nextLong();
    	}
    	long tmp = 0L;
    	long hunt = 0L;
    	for (int i = 0; i < N; i++) {
    		long B = sc.nextLong();
    		long Btmp = B + tmp;
    		if (Ai[i] <= B + tmp) {
    			if (Ai[i] <= tmp) {
    				tmp = B;
    			} else {
    				tmp = B + tmp - Ai[i];
    			}
    			hunt += Ai[i];
    		} else {
    			tmp = 0L;
    			hunt += Btmp;
    		}
    	}
    	if (Ai[N] <= tmp) {
    		hunt += Ai[N];
    	} else {
    		hunt += tmp;
    	}
    	System.out.println(hunt);
    }
} public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	long[] Ai = new long[N+1];
    	for (int i = 0; i < Ai.length; i++) {
    		Ai[i] = sc.nextLong();
    	}
    	long tmp = 0L;
    	long hunt = 0L;
    	for (int i = 0; i < N; i++) {
    		long B = sc.nextLong();
    		long Btmp = B + tmp;
    		if (Ai[i] <= B + tmp) {
    			if (Ai[i] <= tmp) {
    				tmp = B;
    			} else {
    				tmp = B + tmp - Ai[i];
    			}
    			hunt += Ai[i];
    		} else {
    			tmp = 0L;
    			hunt += Btmp;
    		}
    	}
    	if (Ai[N] <= tmp) {
    		hunt += Ai[N];
    	} else {
    		hunt += tmp;
    	}
    	System.out.println(hunt);
    }
} Main
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	long[] Ai = new long[N+1];
    	for (int i = 0; i < Ai.length; i++) {
    		Ai[i] = sc.nextLong();
    	}
    	long tmp = 0L;
    	long hunt = 0L;
    	for (int i = 0; i < N; i++) {
    		long B = sc.nextLong();
    		long Btmp = B + tmp;
    		if (Ai[i] <= B + tmp) {
    			if (Ai[i] <= tmp) {
    				tmp = B;
    			} else {
    				tmp = B + tmp - Ai[i];
    			}
    			hunt += Ai[i];
    		} else {
    			tmp = 0L;
    			hunt += Btmp;
    		}
    	}
    	if (Ai[N] <= tmp) {
    		hunt += Ai[N];
    	} else {
    		hunt += tmp;
    	}
    	System.out.println(hunt);
    }
}