
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] town = new int[N+1];
		int[] hero = new int[N];
		int diff =0;
		for(int i =0;i<N+1;i++) {
			town[i] = scan.nextInt();
		}

		long count = 0;
		for(int i =0;i<N;i++) {
			hero[i] = scan.nextInt();
			if (town[i]<hero[i]) {
				count += town[i];
				hero[i] -= town[i];
				town[i] = 0;

				if(town[i+1]<hero[i]) {
					count += town[i+1];
					hero[i] -= town[i+1];
					town[i+1] = 0;
				} else {
					count += hero[i];
					town[i+1] -= hero[i];
					hero[i]=0;
				}
			} else {
				count += hero[i];
				town[i] -= hero[i];
				hero[i]=0;
			}
		}
		System.out.println(count);
		scan.close();
	}

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

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] town = new int[N+1];
		int[] hero = new int[N];
		int diff =0;
		for(int i =0;i<N+1;i++) {
			town[i] = scan.nextInt();
		}

		long count = 0;
		for(int i =0;i<N;i++) {
			hero[i] = scan.nextInt();
			if (town[i]<hero[i]) {
				count += town[i];
				hero[i] -= town[i];
				town[i] = 0;

				if(town[i+1]<hero[i]) {
					count += town[i+1];
					hero[i] -= town[i+1];
					town[i+1] = 0;
				} else {
					count += hero[i];
					town[i+1] -= hero[i];
					hero[i]=0;
				}
			} else {
				count += hero[i];
				town[i] -= hero[i];
				hero[i]=0;
			}
		}
		System.out.println(count);
		scan.close();
	}

} Main public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] town = new int[N+1];
		int[] hero = new int[N];
		int diff =0;
		for(int i =0;i<N+1;i++) {
			town[i] = scan.nextInt();
		}

		long count = 0;
		for(int i =0;i<N;i++) {
			hero[i] = scan.nextInt();
			if (town[i]<hero[i]) {
				count += town[i];
				hero[i] -= town[i];
				town[i] = 0;

				if(town[i+1]<hero[i]) {
					count += town[i+1];
					hero[i] -= town[i+1];
					town[i+1] = 0;
				} else {
					count += hero[i];
					town[i+1] -= hero[i];
					hero[i]=0;
				}
			} else {
				count += hero[i];
				town[i] -= hero[i];
				hero[i]=0;
			}
		}
		System.out.println(count);
		scan.close();
	} main {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] town = new int[N+1];
		int[] hero = new int[N];
		int diff =0;
		for(int i =0;i<N+1;i++) {
			town[i] = scan.nextInt();
		}

		long count = 0;
		for(int i =0;i<N;i++) {
			hero[i] = scan.nextInt();
			if (town[i]<hero[i]) {
				count += town[i];
				hero[i] -= town[i];
				town[i] = 0;

				if(town[i+1]<hero[i]) {
					count += town[i+1];
					hero[i] -= town[i+1];
					town[i+1] = 0;
				} else {
					count += hero[i];
					town[i+1] -= hero[i];
					hero[i]=0;
				}
			} else {
				count += hero[i];
				town[i] -= hero[i];
				hero[i]=0;
			}
		}
		System.out.println(count);
		scan.close();
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan int[] town = new int[N+1]; town new int[N+1] N+1 N 1 int[] hero = new int[N]; hero new int[N] N int diff =0; diff 0 for(int i =0;i<N+1;i++) {
			town[i] = scan.nextInt();
		} int i =0; int i =0; i 0 i<N+1 i N+1 N 1 i++ i++ i {
			town[i] = scan.nextInt();
		} {
			town[i] = scan.nextInt();
		} town[i] = scan.nextInt() town[i] town i scan.nextInt() scan.nextInt scan long count = 0; count 0 for(int i =0;i<N;i++) {
			hero[i] = scan.nextInt();
			if (town[i]<hero[i]) {
				count += town[i];
				hero[i] -= town[i];
				town[i] = 0;

				if(town[i+1]<hero[i]) {
					count += town[i+1];
					hero[i] -= town[i+1];
					town[i+1] = 0;
				} else {
					count += hero[i];
					town[i+1] -= hero[i];
					hero[i]=0;
				}
			} else {
				count += hero[i];
				town[i] -= hero[i];
				hero[i]=0;
			}
		} int i =0; int i =0; i 0 i<N i N i++ i++ i {
			hero[i] = scan.nextInt();
			if (town[i]<hero[i]) {
				count += town[i];
				hero[i] -= town[i];
				town[i] = 0;

				if(town[i+1]<hero[i]) {
					count += town[i+1];
					hero[i] -= town[i+1];
					town[i+1] = 0;
				} else {
					count += hero[i];
					town[i+1] -= hero[i];
					hero[i]=0;
				}
			} else {
				count += hero[i];
				town[i] -= hero[i];
				hero[i]=0;
			}
		} {
			hero[i] = scan.nextInt();
			if (town[i]<hero[i]) {
				count += town[i];
				hero[i] -= town[i];
				town[i] = 0;

				if(town[i+1]<hero[i]) {
					count += town[i+1];
					hero[i] -= town[i+1];
					town[i+1] = 0;
				} else {
					count += hero[i];
					town[i+1] -= hero[i];
					hero[i]=0;
				}
			} else {
				count += hero[i];
				town[i] -= hero[i];
				hero[i]=0;
			}
		} hero[i] = scan.nextInt() hero[i] hero i scan.nextInt() scan.nextInt scan if (town[i]<hero[i]) {
				count += town[i];
				hero[i] -= town[i];
				town[i] = 0;

				if(town[i+1]<hero[i]) {
					count += town[i+1];
					hero[i] -= town[i+1];
					town[i+1] = 0;
				} else {
					count += hero[i];
					town[i+1] -= hero[i];
					hero[i]=0;
				}
			} else {
				count += hero[i];
				town[i] -= hero[i];
				hero[i]=0;
			} town[i]<hero[i] town[i] town i hero[i] hero i {
				count += town[i];
				hero[i] -= town[i];
				town[i] = 0;

				if(town[i+1]<hero[i]) {
					count += town[i+1];
					hero[i] -= town[i+1];
					town[i+1] = 0;
				} else {
					count += hero[i];
					town[i+1] -= hero[i];
					hero[i]=0;
				}
			} count += town[i] count town[i] town i hero[i] -= town[i] hero[i] hero i town[i] town i town[i] = 0 town[i] town i 0 if(town[i+1]<hero[i]) {
					count += town[i+1];
					hero[i] -= town[i+1];
					town[i+1] = 0;
				} else {
					count += hero[i];
					town[i+1] -= hero[i];
					hero[i]=0;
				} town[i+1]<hero[i] town[i+1] town i+1 i 1 hero[i] hero i {
					count += town[i+1];
					hero[i] -= town[i+1];
					town[i+1] = 0;
				} count += town[i+1] count town[i+1] town i+1 i 1 hero[i] -= town[i+1] hero[i] hero i town[i+1] town i+1 i 1 town[i+1] = 0 town[i+1] town i+1 i 1 0 {
					count += hero[i];
					town[i+1] -= hero[i];
					hero[i]=0;
				} count += hero[i] count hero[i] hero i town[i+1] -= hero[i] town[i+1] town i+1 i 1 hero[i] hero i hero[i]=0 hero[i] hero i 0 {
				count += hero[i];
				town[i] -= hero[i];
				hero[i]=0;
			} count += hero[i] count hero[i] hero i town[i] -= hero[i] town[i] town i hero[i] hero i hero[i]=0 hero[i] hero i 0 System.out.println(count) System.out.println System.out System System.out count scan.close() scan.close scan String[] args args public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] town = new int[N+1];
		int[] hero = new int[N];
		int diff =0;
		for(int i =0;i<N+1;i++) {
			town[i] = scan.nextInt();
		}

		long count = 0;
		for(int i =0;i<N;i++) {
			hero[i] = scan.nextInt();
			if (town[i]<hero[i]) {
				count += town[i];
				hero[i] -= town[i];
				town[i] = 0;

				if(town[i+1]<hero[i]) {
					count += town[i+1];
					hero[i] -= town[i+1];
					town[i+1] = 0;
				} else {
					count += hero[i];
					town[i+1] -= hero[i];
					hero[i]=0;
				}
			} else {
				count += hero[i];
				town[i] -= hero[i];
				hero[i]=0;
			}
		}
		System.out.println(count);
		scan.close();
	}

} public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] town = new int[N+1];
		int[] hero = new int[N];
		int diff =0;
		for(int i =0;i<N+1;i++) {
			town[i] = scan.nextInt();
		}

		long count = 0;
		for(int i =0;i<N;i++) {
			hero[i] = scan.nextInt();
			if (town[i]<hero[i]) {
				count += town[i];
				hero[i] -= town[i];
				town[i] = 0;

				if(town[i+1]<hero[i]) {
					count += town[i+1];
					hero[i] -= town[i+1];
					town[i+1] = 0;
				} else {
					count += hero[i];
					town[i+1] -= hero[i];
					hero[i]=0;
				}
			} else {
				count += hero[i];
				town[i] -= hero[i];
				hero[i]=0;
			}
		}
		System.out.println(count);
		scan.close();
	}

} Main

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] town = new int[N+1];
		int[] hero = new int[N];
		int diff =0;
		for(int i =0;i<N+1;i++) {
			town[i] = scan.nextInt();
		}

		long count = 0;
		for(int i =0;i<N;i++) {
			hero[i] = scan.nextInt();
			if (town[i]<hero[i]) {
				count += town[i];
				hero[i] -= town[i];
				town[i] = 0;

				if(town[i+1]<hero[i]) {
					count += town[i+1];
					hero[i] -= town[i+1];
					town[i+1] = 0;
				} else {
					count += hero[i];
					town[i+1] -= hero[i];
					hero[i]=0;
				}
			} else {
				count += hero[i];
				town[i] -= hero[i];
				hero[i]=0;
			}
		}
		System.out.println(count);
		scan.close();
	}

}

