import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		List<Long> cityList = new ArrayList();
		for (int i=-1; i<n; i++) {
			cityList.add(scan.nextLong());
		}
		
		List<Long> monsterList = new ArrayList();
		for (int i=0; i<n; i++) {
			monsterList.add(scan.nextLong());
		}
		
		long killedMonster = 0;
		for (int i=0; i<n; i++) {
			long city = cityList.get(i);
			long city2 = cityList.get(i+1);
			long killableMonster = monsterList.get(i);
			long amariMonster = city - killableMonster;
			long amariMonster2 = (city + city2) - killableMonster;
			
			if (amariMonster >= 0) {
				killedMonster += killableMonster;
			} else if (amariMonster2 >= 0) {
				killedMonster += killableMonster;
				cityList.set(i+1, (city2 - (killableMonster - city)));
			} else {
				killedMonster += city + city2;
				cityList.set(i+1, (long) 0);
			}
		}
		
		System.out.println(killedMonster);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		List<Long> cityList = new ArrayList();
		for (int i=-1; i<n; i++) {
			cityList.add(scan.nextLong());
		}
		
		List<Long> monsterList = new ArrayList();
		for (int i=0; i<n; i++) {
			monsterList.add(scan.nextLong());
		}
		
		long killedMonster = 0;
		for (int i=0; i<n; i++) {
			long city = cityList.get(i);
			long city2 = cityList.get(i+1);
			long killableMonster = monsterList.get(i);
			long amariMonster = city - killableMonster;
			long amariMonster2 = (city + city2) - killableMonster;
			
			if (amariMonster >= 0) {
				killedMonster += killableMonster;
			} else if (amariMonster2 >= 0) {
				killedMonster += killableMonster;
				cityList.set(i+1, (city2 - (killableMonster - city)));
			} else {
				killedMonster += city + city2;
				cityList.set(i+1, (long) 0);
			}
		}
		
		System.out.println(killedMonster);
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		List<Long> cityList = new ArrayList();
		for (int i=-1; i<n; i++) {
			cityList.add(scan.nextLong());
		}
		
		List<Long> monsterList = new ArrayList();
		for (int i=0; i<n; i++) {
			monsterList.add(scan.nextLong());
		}
		
		long killedMonster = 0;
		for (int i=0; i<n; i++) {
			long city = cityList.get(i);
			long city2 = cityList.get(i+1);
			long killableMonster = monsterList.get(i);
			long amariMonster = city - killableMonster;
			long amariMonster2 = (city + city2) - killableMonster;
			
			if (amariMonster >= 0) {
				killedMonster += killableMonster;
			} else if (amariMonster2 >= 0) {
				killedMonster += killableMonster;
				cityList.set(i+1, (city2 - (killableMonster - city)));
			} else {
				killedMonster += city + city2;
				cityList.set(i+1, (long) 0);
			}
		}
		
		System.out.println(killedMonster);
	} main {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		List<Long> cityList = new ArrayList();
		for (int i=-1; i<n; i++) {
			cityList.add(scan.nextLong());
		}
		
		List<Long> monsterList = new ArrayList();
		for (int i=0; i<n; i++) {
			monsterList.add(scan.nextLong());
		}
		
		long killedMonster = 0;
		for (int i=0; i<n; i++) {
			long city = cityList.get(i);
			long city2 = cityList.get(i+1);
			long killableMonster = monsterList.get(i);
			long amariMonster = city - killableMonster;
			long amariMonster2 = (city + city2) - killableMonster;
			
			if (amariMonster >= 0) {
				killedMonster += killableMonster;
			} else if (amariMonster2 >= 0) {
				killedMonster += killableMonster;
				cityList.set(i+1, (city2 - (killableMonster - city)));
			} else {
				killedMonster += city + city2;
				cityList.set(i+1, (long) 0);
			}
		}
		
		System.out.println(killedMonster);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan List<Long> cityList = new ArrayList(); cityList new ArrayList() for (int i=-1; i<n; i++) {
			cityList.add(scan.nextLong());
		} int i=-1; int i=-1; i -1 1 i<n i n i++ i++ i {
			cityList.add(scan.nextLong());
		} {
			cityList.add(scan.nextLong());
		} cityList.add(scan.nextLong()) cityList.add cityList scan.nextLong() scan.nextLong scan List<Long> monsterList = new ArrayList(); monsterList new ArrayList() for (int i=0; i<n; i++) {
			monsterList.add(scan.nextLong());
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			monsterList.add(scan.nextLong());
		} {
			monsterList.add(scan.nextLong());
		} monsterList.add(scan.nextLong()) monsterList.add monsterList scan.nextLong() scan.nextLong scan long killedMonster = 0; killedMonster 0 for (int i=0; i<n; i++) {
			long city = cityList.get(i);
			long city2 = cityList.get(i+1);
			long killableMonster = monsterList.get(i);
			long amariMonster = city - killableMonster;
			long amariMonster2 = (city + city2) - killableMonster;
			
			if (amariMonster >= 0) {
				killedMonster += killableMonster;
			} else if (amariMonster2 >= 0) {
				killedMonster += killableMonster;
				cityList.set(i+1, (city2 - (killableMonster - city)));
			} else {
				killedMonster += city + city2;
				cityList.set(i+1, (long) 0);
			}
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			long city = cityList.get(i);
			long city2 = cityList.get(i+1);
			long killableMonster = monsterList.get(i);
			long amariMonster = city - killableMonster;
			long amariMonster2 = (city + city2) - killableMonster;
			
			if (amariMonster >= 0) {
				killedMonster += killableMonster;
			} else if (amariMonster2 >= 0) {
				killedMonster += killableMonster;
				cityList.set(i+1, (city2 - (killableMonster - city)));
			} else {
				killedMonster += city + city2;
				cityList.set(i+1, (long) 0);
			}
		} {
			long city = cityList.get(i);
			long city2 = cityList.get(i+1);
			long killableMonster = monsterList.get(i);
			long amariMonster = city - killableMonster;
			long amariMonster2 = (city + city2) - killableMonster;
			
			if (amariMonster >= 0) {
				killedMonster += killableMonster;
			} else if (amariMonster2 >= 0) {
				killedMonster += killableMonster;
				cityList.set(i+1, (city2 - (killableMonster - city)));
			} else {
				killedMonster += city + city2;
				cityList.set(i+1, (long) 0);
			}
		} long city = cityList.get(i); city cityList.get(i) cityList.get cityList i long city2 = cityList.get(i+1); city2 cityList.get(i+1) cityList.get cityList i+1 i 1 long killableMonster = monsterList.get(i); killableMonster monsterList.get(i) monsterList.get monsterList i long amariMonster = city - killableMonster; amariMonster city - killableMonster city killableMonster long amariMonster2 = (city + city2) - killableMonster; amariMonster2 (city + city2) - killableMonster (city + city2) city city2 killableMonster if (amariMonster >= 0) {
				killedMonster += killableMonster;
			} else if (amariMonster2 >= 0) {
				killedMonster += killableMonster;
				cityList.set(i+1, (city2 - (killableMonster - city)));
			} else {
				killedMonster += city + city2;
				cityList.set(i+1, (long) 0);
			} amariMonster >= 0 amariMonster 0 {
				killedMonster += killableMonster;
			} killedMonster += killableMonster killedMonster killableMonster if (amariMonster2 >= 0) {
				killedMonster += killableMonster;
				cityList.set(i+1, (city2 - (killableMonster - city)));
			} else {
				killedMonster += city + city2;
				cityList.set(i+1, (long) 0);
			} amariMonster2 >= 0 amariMonster2 0 {
				killedMonster += killableMonster;
				cityList.set(i+1, (city2 - (killableMonster - city)));
			} killedMonster += killableMonster killedMonster killableMonster cityList.set(i+1, (city2 - (killableMonster - city))) cityList.set cityList i+1 i 1 (city2 - (killableMonster - city)) city2 (killableMonster - city) killableMonster city {
				killedMonster += city + city2;
				cityList.set(i+1, (long) 0);
			} killedMonster += city + city2 killedMonster city + city2 city city2 cityList.set(i+1, (long) 0) cityList.set cityList i+1 i 1 (long) 0 System.out.println(killedMonster) System.out.println System.out System System.out killedMonster String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		List<Long> cityList = new ArrayList();
		for (int i=-1; i<n; i++) {
			cityList.add(scan.nextLong());
		}
		
		List<Long> monsterList = new ArrayList();
		for (int i=0; i<n; i++) {
			monsterList.add(scan.nextLong());
		}
		
		long killedMonster = 0;
		for (int i=0; i<n; i++) {
			long city = cityList.get(i);
			long city2 = cityList.get(i+1);
			long killableMonster = monsterList.get(i);
			long amariMonster = city - killableMonster;
			long amariMonster2 = (city + city2) - killableMonster;
			
			if (amariMonster >= 0) {
				killedMonster += killableMonster;
			} else if (amariMonster2 >= 0) {
				killedMonster += killableMonster;
				cityList.set(i+1, (city2 - (killableMonster - city)));
			} else {
				killedMonster += city + city2;
				cityList.set(i+1, (long) 0);
			}
		}
		
		System.out.println(killedMonster);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		List<Long> cityList = new ArrayList();
		for (int i=-1; i<n; i++) {
			cityList.add(scan.nextLong());
		}
		
		List<Long> monsterList = new ArrayList();
		for (int i=0; i<n; i++) {
			monsterList.add(scan.nextLong());
		}
		
		long killedMonster = 0;
		for (int i=0; i<n; i++) {
			long city = cityList.get(i);
			long city2 = cityList.get(i+1);
			long killableMonster = monsterList.get(i);
			long amariMonster = city - killableMonster;
			long amariMonster2 = (city + city2) - killableMonster;
			
			if (amariMonster >= 0) {
				killedMonster += killableMonster;
			} else if (amariMonster2 >= 0) {
				killedMonster += killableMonster;
				cityList.set(i+1, (city2 - (killableMonster - city)));
			} else {
				killedMonster += city + city2;
				cityList.set(i+1, (long) 0);
			}
		}
		
		System.out.println(killedMonster);
	}
} Main
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		List<Long> cityList = new ArrayList();
		for (int i=-1; i<n; i++) {
			cityList.add(scan.nextLong());
		}
		
		List<Long> monsterList = new ArrayList();
		for (int i=0; i<n; i++) {
			monsterList.add(scan.nextLong());
		}
		
		long killedMonster = 0;
		for (int i=0; i<n; i++) {
			long city = cityList.get(i);
			long city2 = cityList.get(i+1);
			long killableMonster = monsterList.get(i);
			long amariMonster = city - killableMonster;
			long amariMonster2 = (city + city2) - killableMonster;
			
			if (amariMonster >= 0) {
				killedMonster += killableMonster;
			} else if (amariMonster2 >= 0) {
				killedMonster += killableMonster;
				cityList.set(i+1, (city2 - (killableMonster - city)));
			} else {
				killedMonster += city + city2;
				cityList.set(i+1, (long) 0);
			}
		}
		
		System.out.println(killedMonster);
	}
}