
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        long[] A = new long[N + 1];
        long[] B = new long[N];

        for (int i = 0 ; i < N + 1 ; i++) {
            A[i] = scanner.nextLong();
        }

        for (int i = 0 ; i < N ; i++) {
            B[i] = scanner.nextLong();
        }

        long answer = 0;
        for (int i = 0 ; i < N ; i++) {
            answer += Math.min(A[i], B[i]);
            B[i] = B[i] - Math.min(A[i], B[i]);
            answer += Math.min(A[i + 1], B[i]);
            A[i + 1] -= Math.min(A[i + 1], B[i]);
        }

        System.out.println(answer);
      }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        long[] A = new long[N + 1];
        long[] B = new long[N];

        for (int i = 0 ; i < N + 1 ; i++) {
            A[i] = scanner.nextLong();
        }

        for (int i = 0 ; i < N ; i++) {
            B[i] = scanner.nextLong();
        }

        long answer = 0;
        for (int i = 0 ; i < N ; i++) {
            answer += Math.min(A[i], B[i]);
            B[i] = B[i] - Math.min(A[i], B[i]);
            answer += Math.min(A[i + 1], B[i]);
            A[i + 1] -= Math.min(A[i + 1], B[i]);
        }

        System.out.println(answer);
      }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        long[] A = new long[N + 1];
        long[] B = new long[N];

        for (int i = 0 ; i < N + 1 ; i++) {
            A[i] = scanner.nextLong();
        }

        for (int i = 0 ; i < N ; i++) {
            B[i] = scanner.nextLong();
        }

        long answer = 0;
        for (int i = 0 ; i < N ; i++) {
            answer += Math.min(A[i], B[i]);
            B[i] = B[i] - Math.min(A[i], B[i]);
            answer += Math.min(A[i + 1], B[i]);
            A[i + 1] -= Math.min(A[i + 1], B[i]);
        }

        System.out.println(answer);
      } main {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        long[] A = new long[N + 1];
        long[] B = new long[N];

        for (int i = 0 ; i < N + 1 ; i++) {
            A[i] = scanner.nextLong();
        }

        for (int i = 0 ; i < N ; i++) {
            B[i] = scanner.nextLong();
        }

        long answer = 0;
        for (int i = 0 ; i < N ; i++) {
            answer += Math.min(A[i], B[i]);
            B[i] = B[i] - Math.min(A[i], B[i]);
            answer += Math.min(A[i + 1], B[i]);
            A[i + 1] -= Math.min(A[i + 1], B[i]);
        }

        System.out.println(answer);
      } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner long[] A = new long[N + 1]; A new long[N + 1] N + 1 N 1 long[] B = new long[N]; B new long[N] N for (int i = 0 ; i < N + 1 ; i++) {
            A[i] = scanner.nextLong();
        } int i = 0 ; int i = 0 ; i 0 i < N + 1 i N + 1 N 1 i++ i++ i {
            A[i] = scanner.nextLong();
        } {
            A[i] = scanner.nextLong();
        } A[i] = scanner.nextLong() A[i] A i scanner.nextLong() scanner.nextLong scanner for (int i = 0 ; i < N ; i++) {
            B[i] = scanner.nextLong();
        } int i = 0 ; int i = 0 ; i 0 i < N i N i++ i++ i {
            B[i] = scanner.nextLong();
        } {
            B[i] = scanner.nextLong();
        } B[i] = scanner.nextLong() B[i] B i scanner.nextLong() scanner.nextLong scanner long answer = 0; answer 0 for (int i = 0 ; i < N ; i++) {
            answer += Math.min(A[i], B[i]);
            B[i] = B[i] - Math.min(A[i], B[i]);
            answer += Math.min(A[i + 1], B[i]);
            A[i + 1] -= Math.min(A[i + 1], B[i]);
        } int i = 0 ; int i = 0 ; i 0 i < N i N i++ i++ i {
            answer += Math.min(A[i], B[i]);
            B[i] = B[i] - Math.min(A[i], B[i]);
            answer += Math.min(A[i + 1], B[i]);
            A[i + 1] -= Math.min(A[i + 1], B[i]);
        } {
            answer += Math.min(A[i], B[i]);
            B[i] = B[i] - Math.min(A[i], B[i]);
            answer += Math.min(A[i + 1], B[i]);
            A[i + 1] -= Math.min(A[i + 1], B[i]);
        } answer += Math.min(A[i], B[i]) answer Math.min(A[i], B[i]) Math.min Math A[i] A i B[i] B i B[i] = B[i] - Math.min(A[i], B[i]) B[i] B i B[i] - Math.min(A[i], B[i]) B[i] B i Math.min(A[i], B[i]) Math.min Math A[i] A i B[i] B i answer += Math.min(A[i + 1], B[i]) answer Math.min(A[i + 1], B[i]) Math.min Math A[i + 1] A i + 1 i 1 B[i] B i A[i + 1] -= Math.min(A[i + 1], B[i]) A[i + 1] A i + 1 i 1 Math.min(A[i + 1], B[i]) Math.min Math A[i + 1] A i + 1 i 1 B[i] B i System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        long[] A = new long[N + 1];
        long[] B = new long[N];

        for (int i = 0 ; i < N + 1 ; i++) {
            A[i] = scanner.nextLong();
        }

        for (int i = 0 ; i < N ; i++) {
            B[i] = scanner.nextLong();
        }

        long answer = 0;
        for (int i = 0 ; i < N ; i++) {
            answer += Math.min(A[i], B[i]);
            B[i] = B[i] - Math.min(A[i], B[i]);
            answer += Math.min(A[i + 1], B[i]);
            A[i + 1] -= Math.min(A[i + 1], B[i]);
        }

        System.out.println(answer);
      }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        long[] A = new long[N + 1];
        long[] B = new long[N];

        for (int i = 0 ; i < N + 1 ; i++) {
            A[i] = scanner.nextLong();
        }

        for (int i = 0 ; i < N ; i++) {
            B[i] = scanner.nextLong();
        }

        long answer = 0;
        for (int i = 0 ; i < N ; i++) {
            answer += Math.min(A[i], B[i]);
            B[i] = B[i] - Math.min(A[i], B[i]);
            answer += Math.min(A[i + 1], B[i]);
            A[i + 1] -= Math.min(A[i + 1], B[i]);
        }

        System.out.println(answer);
      }
} Main

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        long[] A = new long[N + 1];
        long[] B = new long[N];

        for (int i = 0 ; i < N + 1 ; i++) {
            A[i] = scanner.nextLong();
        }

        for (int i = 0 ; i < N ; i++) {
            B[i] = scanner.nextLong();
        }

        long answer = 0;
        for (int i = 0 ; i < N ; i++) {
            answer += Math.min(A[i], B[i]);
            B[i] = B[i] - Math.min(A[i], B[i]);
            answer += Math.min(A[i + 1], B[i]);
            A[i + 1] -= Math.min(A[i + 1], B[i]);
        }

        System.out.println(answer);
      }
}
