import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = Long.parseLong(sc.next());
		List<Long> aList = new ArrayList();
		List<Long> bList = new ArrayList();
		
		for(long i=0; i <= N;i++){
			aList.add(Long.parseLong(sc.next()));
		}
		long totalDamage = 0;
		for(long i=0; i < N;i++){
			long a = Long.parseLong(sc.next());
			bList.add(a);
			totalDamage += a;
		}
		
		long amari = -1;
		long more = 0;
		for(int i=0;i<N;i++){
			long a1 = aList.get(i);
			long a2 = aList.get(i+1);
			long b1 = bList.get(i);
			if(amari!=-1){
				a1 = amari;
			}
			if(a1+a2 >b1){
				amari = b1 > a1? a2-(b1-a1): a2;
			}else if(a1 + a2 < b1){
				amari = 0;
				more += b1 - (a1+a2);
			} else {
				amari = 0;
			}
		}
		System.out.println(totalDamage-more);
	}
} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = Long.parseLong(sc.next());
		List<Long> aList = new ArrayList();
		List<Long> bList = new ArrayList();
		
		for(long i=0; i <= N;i++){
			aList.add(Long.parseLong(sc.next()));
		}
		long totalDamage = 0;
		for(long i=0; i < N;i++){
			long a = Long.parseLong(sc.next());
			bList.add(a);
			totalDamage += a;
		}
		
		long amari = -1;
		long more = 0;
		for(int i=0;i<N;i++){
			long a1 = aList.get(i);
			long a2 = aList.get(i+1);
			long b1 = bList.get(i);
			if(amari!=-1){
				a1 = amari;
			}
			if(a1+a2 >b1){
				amari = b1 > a1? a2-(b1-a1): a2;
			}else if(a1 + a2 < b1){
				amari = 0;
				more += b1 - (a1+a2);
			} else {
				amari = 0;
			}
		}
		System.out.println(totalDamage-more);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = Long.parseLong(sc.next());
		List<Long> aList = new ArrayList();
		List<Long> bList = new ArrayList();
		
		for(long i=0; i <= N;i++){
			aList.add(Long.parseLong(sc.next()));
		}
		long totalDamage = 0;
		for(long i=0; i < N;i++){
			long a = Long.parseLong(sc.next());
			bList.add(a);
			totalDamage += a;
		}
		
		long amari = -1;
		long more = 0;
		for(int i=0;i<N;i++){
			long a1 = aList.get(i);
			long a2 = aList.get(i+1);
			long b1 = bList.get(i);
			if(amari!=-1){
				a1 = amari;
			}
			if(a1+a2 >b1){
				amari = b1 > a1? a2-(b1-a1): a2;
			}else if(a1 + a2 < b1){
				amari = 0;
				more += b1 - (a1+a2);
			} else {
				amari = 0;
			}
		}
		System.out.println(totalDamage-more);
	} main {
		Scanner sc = new Scanner(System.in);
		long N = Long.parseLong(sc.next());
		List<Long> aList = new ArrayList();
		List<Long> bList = new ArrayList();
		
		for(long i=0; i <= N;i++){
			aList.add(Long.parseLong(sc.next()));
		}
		long totalDamage = 0;
		for(long i=0; i < N;i++){
			long a = Long.parseLong(sc.next());
			bList.add(a);
			totalDamage += a;
		}
		
		long amari = -1;
		long more = 0;
		for(int i=0;i<N;i++){
			long a1 = aList.get(i);
			long a2 = aList.get(i+1);
			long b1 = bList.get(i);
			if(amari!=-1){
				a1 = amari;
			}
			if(a1+a2 >b1){
				amari = b1 > a1? a2-(b1-a1): a2;
			}else if(a1 + a2 < b1){
				amari = 0;
				more += b1 - (a1+a2);
			} else {
				amari = 0;
			}
		}
		System.out.println(totalDamage-more);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long N = Long.parseLong(sc.next()); N Long.parseLong(sc.next()) Long.parseLong Long sc.next() sc.next sc List<Long> aList = new ArrayList(); aList new ArrayList() List<Long> bList = new ArrayList(); bList new ArrayList() for(long i=0; i <= N;i++){
			aList.add(Long.parseLong(sc.next()));
		} long i=0; long i=0; i 0 i <= N i N i++ i++ i {
			aList.add(Long.parseLong(sc.next()));
		} {
			aList.add(Long.parseLong(sc.next()));
		} aList.add(Long.parseLong(sc.next())) aList.add aList Long.parseLong(sc.next()) Long.parseLong Long sc.next() sc.next sc long totalDamage = 0; totalDamage 0 for(long i=0; i < N;i++){
			long a = Long.parseLong(sc.next());
			bList.add(a);
			totalDamage += a;
		} long i=0; long i=0; i 0 i < N i N i++ i++ i {
			long a = Long.parseLong(sc.next());
			bList.add(a);
			totalDamage += a;
		} {
			long a = Long.parseLong(sc.next());
			bList.add(a);
			totalDamage += a;
		} long a = Long.parseLong(sc.next()); a Long.parseLong(sc.next()) Long.parseLong Long sc.next() sc.next sc bList.add(a) bList.add bList a totalDamage += a totalDamage a long amari = -1; amari -1 1 long more = 0; more 0 for(int i=0;i<N;i++){
			long a1 = aList.get(i);
			long a2 = aList.get(i+1);
			long b1 = bList.get(i);
			if(amari!=-1){
				a1 = amari;
			}
			if(a1+a2 >b1){
				amari = b1 > a1? a2-(b1-a1): a2;
			}else if(a1 + a2 < b1){
				amari = 0;
				more += b1 - (a1+a2);
			} else {
				amari = 0;
			}
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			long a1 = aList.get(i);
			long a2 = aList.get(i+1);
			long b1 = bList.get(i);
			if(amari!=-1){
				a1 = amari;
			}
			if(a1+a2 >b1){
				amari = b1 > a1? a2-(b1-a1): a2;
			}else if(a1 + a2 < b1){
				amari = 0;
				more += b1 - (a1+a2);
			} else {
				amari = 0;
			}
		} {
			long a1 = aList.get(i);
			long a2 = aList.get(i+1);
			long b1 = bList.get(i);
			if(amari!=-1){
				a1 = amari;
			}
			if(a1+a2 >b1){
				amari = b1 > a1? a2-(b1-a1): a2;
			}else if(a1 + a2 < b1){
				amari = 0;
				more += b1 - (a1+a2);
			} else {
				amari = 0;
			}
		} long a1 = aList.get(i); a1 aList.get(i) aList.get aList i long a2 = aList.get(i+1); a2 aList.get(i+1) aList.get aList i+1 i 1 long b1 = bList.get(i); b1 bList.get(i) bList.get bList i if(amari!=-1){
				a1 = amari;
			} amari!=-1 amari -1 1 {
				a1 = amari;
			} a1 = amari a1 amari if(a1+a2 >b1){
				amari = b1 > a1? a2-(b1-a1): a2;
			}else if(a1 + a2 < b1){
				amari = 0;
				more += b1 - (a1+a2);
			} else {
				amari = 0;
			} a1+a2 >b1 a1+a2 a1 a2 b1 {
				amari = b1 > a1? a2-(b1-a1): a2;
			} amari = b1 > a1? a2-(b1-a1): a2 amari b1 > a1? a2-(b1-a1): a2 b1 > a1 b1 a1 a2-(b1-a1) a2 (b1-a1) b1 a1 a2 if(a1 + a2 < b1){
				amari = 0;
				more += b1 - (a1+a2);
			} else {
				amari = 0;
			} a1 + a2 < b1 a1 + a2 a1 a2 b1 {
				amari = 0;
				more += b1 - (a1+a2);
			} amari = 0 amari 0 more += b1 - (a1+a2) more b1 - (a1+a2) b1 (a1+a2) a1 a2 {
				amari = 0;
			} amari = 0 amari 0 System.out.println(totalDamage-more) System.out.println System.out System System.out totalDamage-more totalDamage more String[] args args
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = Long.parseLong(sc.next());
		List<Long> aList = new ArrayList();
		List<Long> bList = new ArrayList();
		
		for(long i=0; i <= N;i++){
			aList.add(Long.parseLong(sc.next()));
		}
		long totalDamage = 0;
		for(long i=0; i < N;i++){
			long a = Long.parseLong(sc.next());
			bList.add(a);
			totalDamage += a;
		}
		
		long amari = -1;
		long more = 0;
		for(int i=0;i<N;i++){
			long a1 = aList.get(i);
			long a2 = aList.get(i+1);
			long b1 = bList.get(i);
			if(amari!=-1){
				a1 = amari;
			}
			if(a1+a2 >b1){
				amari = b1 > a1? a2-(b1-a1): a2;
			}else if(a1 + a2 < b1){
				amari = 0;
				more += b1 - (a1+a2);
			} else {
				amari = 0;
			}
		}
		System.out.println(totalDamage-more);
	}
}
