import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] a = new int[n + 2];
		int[] b = new int[n + 1];
		for ( int i = 1; i <= n + 1; i++ ) {
			a[i] = in.nextInt();
		}
		for ( int i = 1; i <= n; i++ ) {
			b[i] = in.nextInt();
		}

		long beated = 0;
		for ( int i = 1; i <= n; i++ ) {
			// モンスタの方が多いor同数の場合 bを使い切る
			if ( a[i] >= b[i] ) {
				beated += b[i];
				a[i] -= b[i];
				b[i] = 0;
			}
			// 勇者の方が多い場合 aを使い切る
			else if ( a[i] < b[i] ) {
				beated += a[i];
				b[i] -= a[i];
				a[i] = 0;

				// 次の町にも手を出す
				if ( a[i + 1] >= b[i] ) {
					beated += b[i];
					a[i + 1] -= b[i];
					b[i] = 0;

				} else if ( a[i + 1] < b[i] ) {
					beated += a[i + 1];
					b[i] -= a[i + 1];
					a[i + 1] = 0;
				}
			}
		}
		System.out.println(beated);
		in.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] a = new int[n + 2];
		int[] b = new int[n + 1];
		for ( int i = 1; i <= n + 1; i++ ) {
			a[i] = in.nextInt();
		}
		for ( int i = 1; i <= n; i++ ) {
			b[i] = in.nextInt();
		}

		long beated = 0;
		for ( int i = 1; i <= n; i++ ) {
			// モンスタの方が多いor同数の場合 bを使い切る
			if ( a[i] >= b[i] ) {
				beated += b[i];
				a[i] -= b[i];
				b[i] = 0;
			}
			// 勇者の方が多い場合 aを使い切る
			else if ( a[i] < b[i] ) {
				beated += a[i];
				b[i] -= a[i];
				a[i] = 0;

				// 次の町にも手を出す
				if ( a[i + 1] >= b[i] ) {
					beated += b[i];
					a[i + 1] -= b[i];
					b[i] = 0;

				} else if ( a[i + 1] < b[i] ) {
					beated += a[i + 1];
					b[i] -= a[i + 1];
					a[i + 1] = 0;
				}
			}
		}
		System.out.println(beated);
		in.close();
	}
} Main public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] a = new int[n + 2];
		int[] b = new int[n + 1];
		for ( int i = 1; i <= n + 1; i++ ) {
			a[i] = in.nextInt();
		}
		for ( int i = 1; i <= n; i++ ) {
			b[i] = in.nextInt();
		}

		long beated = 0;
		for ( int i = 1; i <= n; i++ ) {
			// モンスタの方が多いor同数の場合 bを使い切る
			if ( a[i] >= b[i] ) {
				beated += b[i];
				a[i] -= b[i];
				b[i] = 0;
			}
			// 勇者の方が多い場合 aを使い切る
			else if ( a[i] < b[i] ) {
				beated += a[i];
				b[i] -= a[i];
				a[i] = 0;

				// 次の町にも手を出す
				if ( a[i + 1] >= b[i] ) {
					beated += b[i];
					a[i + 1] -= b[i];
					b[i] = 0;

				} else if ( a[i + 1] < b[i] ) {
					beated += a[i + 1];
					b[i] -= a[i + 1];
					a[i + 1] = 0;
				}
			}
		}
		System.out.println(beated);
		in.close();
	} main {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] a = new int[n + 2];
		int[] b = new int[n + 1];
		for ( int i = 1; i <= n + 1; i++ ) {
			a[i] = in.nextInt();
		}
		for ( int i = 1; i <= n; i++ ) {
			b[i] = in.nextInt();
		}

		long beated = 0;
		for ( int i = 1; i <= n; i++ ) {
			// モンスタの方が多いor同数の場合 bを使い切る
			if ( a[i] >= b[i] ) {
				beated += b[i];
				a[i] -= b[i];
				b[i] = 0;
			}
			// 勇者の方が多い場合 aを使い切る
			else if ( a[i] < b[i] ) {
				beated += a[i];
				b[i] -= a[i];
				a[i] = 0;

				// 次の町にも手を出す
				if ( a[i + 1] >= b[i] ) {
					beated += b[i];
					a[i + 1] -= b[i];
					b[i] = 0;

				} else if ( a[i + 1] < b[i] ) {
					beated += a[i + 1];
					b[i] -= a[i + 1];
					a[i + 1] = 0;
				}
			}
		}
		System.out.println(beated);
		in.close();
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) int n = in.nextInt(); n in.nextInt() in.nextInt in int[] a = new int[n + 2]; a new int[n + 2] n + 2 n 2 int[] b = new int[n + 1]; b new int[n + 1] n + 1 n 1 for ( int i = 1; i <= n + 1; i++ ) {
			a[i] = in.nextInt();
		} int i = 1; int i = 1; i 1 i <= n + 1 i n + 1 n 1 i++ i++ i {
			a[i] = in.nextInt();
		} {
			a[i] = in.nextInt();
		} a[i] = in.nextInt() a[i] a i in.nextInt() in.nextInt in for ( int i = 1; i <= n; i++ ) {
			b[i] = in.nextInt();
		} int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
			b[i] = in.nextInt();
		} {
			b[i] = in.nextInt();
		} b[i] = in.nextInt() b[i] b i in.nextInt() in.nextInt in long beated = 0; beated 0 for ( int i = 1; i <= n; i++ ) {
			// モンスタの方が多いor同数の場合 bを使い切る
			if ( a[i] >= b[i] ) {
				beated += b[i];
				a[i] -= b[i];
				b[i] = 0;
			}
			// 勇者の方が多い場合 aを使い切る
			else if ( a[i] < b[i] ) {
				beated += a[i];
				b[i] -= a[i];
				a[i] = 0;

				// 次の町にも手を出す
				if ( a[i + 1] >= b[i] ) {
					beated += b[i];
					a[i + 1] -= b[i];
					b[i] = 0;

				} else if ( a[i + 1] < b[i] ) {
					beated += a[i + 1];
					b[i] -= a[i + 1];
					a[i + 1] = 0;
				}
			}
		} int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
			// モンスタの方が多いor同数の場合 bを使い切る
			if ( a[i] >= b[i] ) {
				beated += b[i];
				a[i] -= b[i];
				b[i] = 0;
			}
			// 勇者の方が多い場合 aを使い切る
			else if ( a[i] < b[i] ) {
				beated += a[i];
				b[i] -= a[i];
				a[i] = 0;

				// 次の町にも手を出す
				if ( a[i + 1] >= b[i] ) {
					beated += b[i];
					a[i + 1] -= b[i];
					b[i] = 0;

				} else if ( a[i + 1] < b[i] ) {
					beated += a[i + 1];
					b[i] -= a[i + 1];
					a[i + 1] = 0;
				}
			}
		} {
			// モンスタの方が多いor同数の場合 bを使い切る
			if ( a[i] >= b[i] ) {
				beated += b[i];
				a[i] -= b[i];
				b[i] = 0;
			}
			// 勇者の方が多い場合 aを使い切る
			else if ( a[i] < b[i] ) {
				beated += a[i];
				b[i] -= a[i];
				a[i] = 0;

				// 次の町にも手を出す
				if ( a[i + 1] >= b[i] ) {
					beated += b[i];
					a[i + 1] -= b[i];
					b[i] = 0;

				} else if ( a[i + 1] < b[i] ) {
					beated += a[i + 1];
					b[i] -= a[i + 1];
					a[i + 1] = 0;
				}
			}
		} if ( a[i] >= b[i] ) {
				beated += b[i];
				a[i] -= b[i];
				b[i] = 0;
			}
			// 勇者の方が多い場合 aを使い切る
			else if ( a[i] < b[i] ) {
				beated += a[i];
				b[i] -= a[i];
				a[i] = 0;

				// 次の町にも手を出す
				if ( a[i + 1] >= b[i] ) {
					beated += b[i];
					a[i + 1] -= b[i];
					b[i] = 0;

				} else if ( a[i + 1] < b[i] ) {
					beated += a[i + 1];
					b[i] -= a[i + 1];
					a[i + 1] = 0;
				}
			} a[i] >= b[i] a[i] a i b[i] b i {
				beated += b[i];
				a[i] -= b[i];
				b[i] = 0;
			} beated += b[i] beated b[i] b i a[i] -= b[i] a[i] a i b[i] b i b[i] = 0 b[i] b i 0 if ( a[i] < b[i] ) {
				beated += a[i];
				b[i] -= a[i];
				a[i] = 0;

				// 次の町にも手を出す
				if ( a[i + 1] >= b[i] ) {
					beated += b[i];
					a[i + 1] -= b[i];
					b[i] = 0;

				} else if ( a[i + 1] < b[i] ) {
					beated += a[i + 1];
					b[i] -= a[i + 1];
					a[i + 1] = 0;
				}
			} a[i] < b[i] a[i] a i b[i] b i {
				beated += a[i];
				b[i] -= a[i];
				a[i] = 0;

				// 次の町にも手を出す
				if ( a[i + 1] >= b[i] ) {
					beated += b[i];
					a[i + 1] -= b[i];
					b[i] = 0;

				} else if ( a[i + 1] < b[i] ) {
					beated += a[i + 1];
					b[i] -= a[i + 1];
					a[i + 1] = 0;
				}
			} beated += a[i] beated a[i] a i b[i] -= a[i] b[i] b i a[i] a i a[i] = 0 a[i] a i 0 if ( a[i + 1] >= b[i] ) {
					beated += b[i];
					a[i + 1] -= b[i];
					b[i] = 0;

				} else if ( a[i + 1] < b[i] ) {
					beated += a[i + 1];
					b[i] -= a[i + 1];
					a[i + 1] = 0;
				} a[i + 1] >= b[i] a[i + 1] a i + 1 i 1 b[i] b i {
					beated += b[i];
					a[i + 1] -= b[i];
					b[i] = 0;

				} beated += b[i] beated b[i] b i a[i + 1] -= b[i] a[i + 1] a i + 1 i 1 b[i] b i b[i] = 0 b[i] b i 0 if ( a[i + 1] < b[i] ) {
					beated += a[i + 1];
					b[i] -= a[i + 1];
					a[i + 1] = 0;
				} a[i + 1] < b[i] a[i + 1] a i + 1 i 1 b[i] b i {
					beated += a[i + 1];
					b[i] -= a[i + 1];
					a[i + 1] = 0;
				} beated += a[i + 1] beated a[i + 1] a i + 1 i 1 b[i] -= a[i + 1] b[i] b i a[i + 1] a i + 1 i 1 a[i + 1] = 0 a[i + 1] a i + 1 i 1 0 System.out.println(beated) System.out.println System.out System System.out beated in.close() in.close in String[] args args public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] a = new int[n + 2];
		int[] b = new int[n + 1];
		for ( int i = 1; i <= n + 1; i++ ) {
			a[i] = in.nextInt();
		}
		for ( int i = 1; i <= n; i++ ) {
			b[i] = in.nextInt();
		}

		long beated = 0;
		for ( int i = 1; i <= n; i++ ) {
			// モンスタの方が多いor同数の場合 bを使い切る
			if ( a[i] >= b[i] ) {
				beated += b[i];
				a[i] -= b[i];
				b[i] = 0;
			}
			// 勇者の方が多い場合 aを使い切る
			else if ( a[i] < b[i] ) {
				beated += a[i];
				b[i] -= a[i];
				a[i] = 0;

				// 次の町にも手を出す
				if ( a[i + 1] >= b[i] ) {
					beated += b[i];
					a[i + 1] -= b[i];
					b[i] = 0;

				} else if ( a[i + 1] < b[i] ) {
					beated += a[i + 1];
					b[i] -= a[i + 1];
					a[i + 1] = 0;
				}
			}
		}
		System.out.println(beated);
		in.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] a = new int[n + 2];
		int[] b = new int[n + 1];
		for ( int i = 1; i <= n + 1; i++ ) {
			a[i] = in.nextInt();
		}
		for ( int i = 1; i <= n; i++ ) {
			b[i] = in.nextInt();
		}

		long beated = 0;
		for ( int i = 1; i <= n; i++ ) {
			// モンスタの方が多いor同数の場合 bを使い切る
			if ( a[i] >= b[i] ) {
				beated += b[i];
				a[i] -= b[i];
				b[i] = 0;
			}
			// 勇者の方が多い場合 aを使い切る
			else if ( a[i] < b[i] ) {
				beated += a[i];
				b[i] -= a[i];
				a[i] = 0;

				// 次の町にも手を出す
				if ( a[i + 1] >= b[i] ) {
					beated += b[i];
					a[i + 1] -= b[i];
					b[i] = 0;

				} else if ( a[i + 1] < b[i] ) {
					beated += a[i + 1];
					b[i] -= a[i + 1];
					a[i + 1] = 0;
				}
			}
		}
		System.out.println(beated);
		in.close();
	}
} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] a = new int[n + 2];
		int[] b = new int[n + 1];
		for ( int i = 1; i <= n + 1; i++ ) {
			a[i] = in.nextInt();
		}
		for ( int i = 1; i <= n; i++ ) {
			b[i] = in.nextInt();
		}

		long beated = 0;
		for ( int i = 1; i <= n; i++ ) {
			// モンスタの方が多いor同数の場合 bを使い切る
			if ( a[i] >= b[i] ) {
				beated += b[i];
				a[i] -= b[i];
				b[i] = 0;
			}
			// 勇者の方が多い場合 aを使い切る
			else if ( a[i] < b[i] ) {
				beated += a[i];
				b[i] -= a[i];
				a[i] = 0;

				// 次の町にも手を出す
				if ( a[i + 1] >= b[i] ) {
					beated += b[i];
					a[i + 1] -= b[i];
					b[i] = 0;

				} else if ( a[i + 1] < b[i] ) {
					beated += a[i + 1];
					b[i] -= a[i + 1];
					a[i + 1] = 0;
				}
			}
		}
		System.out.println(beated);
		in.close();
	}
}