import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        boolean debug = false;
        if (debug != false) {
            return;
        }
        System.out.println(str);
    }

    public static void main(String[] args) {

        int N;
        long A[];
        long B[];

        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            A = new long[N+1];
            B = new long[N];
            for(int i =0;i < N+1;i++){
                A[i] = sc.nextLong();
            }
            for(int i =0;i < N;i++){
                B[i] = sc.nextLong();
            }
        }
        long result = 0;
        for(int i =0;i < N;i++){
            if(B[i] > A[i]){
                result += A[i];
                long temp = A[i];
                A[i]-=temp;
                B[i] -=temp;
            }else{
                result += B[i];
                long temp = B[i];
                B[i]-=temp;
                A[i] -=temp;
            }
            if(B[i] > A[i+1]){
                result += A[i+1];
                long temp = A[i+1];
                A[i+1]-=temp;
                B[i] -=temp;
            }else{
                result += B[i];
                long temp = B[i];
                B[i]-=temp;
                A[i+1] -=temp;
            }
        }
        System.out.println(result);




        return;
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void debug(String str) {
        boolean debug = false;
        if (debug != false) {
            return;
        }
        System.out.println(str);
    }

    public static void main(String[] args) {

        int N;
        long A[];
        long B[];

        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            A = new long[N+1];
            B = new long[N];
            for(int i =0;i < N+1;i++){
                A[i] = sc.nextLong();
            }
            for(int i =0;i < N;i++){
                B[i] = sc.nextLong();
            }
        }
        long result = 0;
        for(int i =0;i < N;i++){
            if(B[i] > A[i]){
                result += A[i];
                long temp = A[i];
                A[i]-=temp;
                B[i] -=temp;
            }else{
                result += B[i];
                long temp = B[i];
                B[i]-=temp;
                A[i] -=temp;
            }
            if(B[i] > A[i+1]){
                result += A[i+1];
                long temp = A[i+1];
                A[i+1]-=temp;
                B[i] -=temp;
            }else{
                result += B[i];
                long temp = B[i];
                B[i]-=temp;
                A[i+1] -=temp;
            }
        }
        System.out.println(result);




        return;
    }
} Main public static void debug(String str) {
        boolean debug = false;
        if (debug != false) {
            return;
        }
        System.out.println(str);
    } debug {
        boolean debug = false;
        if (debug != false) {
            return;
        }
        System.out.println(str);
    } boolean debug = false; debug false if (debug != false) {
            return;
        } debug != false debug false {
            return;
        } return; System.out.println(str) System.out.println System.out System System.out str String str str public static void main(String[] args) {

        int N;
        long A[];
        long B[];

        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            A = new long[N+1];
            B = new long[N];
            for(int i =0;i < N+1;i++){
                A[i] = sc.nextLong();
            }
            for(int i =0;i < N;i++){
                B[i] = sc.nextLong();
            }
        }
        long result = 0;
        for(int i =0;i < N;i++){
            if(B[i] > A[i]){
                result += A[i];
                long temp = A[i];
                A[i]-=temp;
                B[i] -=temp;
            }else{
                result += B[i];
                long temp = B[i];
                B[i]-=temp;
                A[i] -=temp;
            }
            if(B[i] > A[i+1]){
                result += A[i+1];
                long temp = A[i+1];
                A[i+1]-=temp;
                B[i] -=temp;
            }else{
                result += B[i];
                long temp = B[i];
                B[i]-=temp;
                A[i+1] -=temp;
            }
        }
        System.out.println(result);




        return;
    } main {

        int N;
        long A[];
        long B[];

        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            A = new long[N+1];
            B = new long[N];
            for(int i =0;i < N+1;i++){
                A[i] = sc.nextLong();
            }
            for(int i =0;i < N;i++){
                B[i] = sc.nextLong();
            }
        }
        long result = 0;
        for(int i =0;i < N;i++){
            if(B[i] > A[i]){
                result += A[i];
                long temp = A[i];
                A[i]-=temp;
                B[i] -=temp;
            }else{
                result += B[i];
                long temp = B[i];
                B[i]-=temp;
                A[i] -=temp;
            }
            if(B[i] > A[i+1]){
                result += A[i+1];
                long temp = A[i+1];
                A[i+1]-=temp;
                B[i] -=temp;
            }else{
                result += B[i];
                long temp = B[i];
                B[i]-=temp;
                A[i+1] -=temp;
            }
        }
        System.out.println(result);




        return;
    } int N; N long A[]; A long B[]; B try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            A = new long[N+1];
            B = new long[N];
            for(int i =0;i < N+1;i++){
                A[i] = sc.nextLong();
            }
            for(int i =0;i < N;i++){
                B[i] = sc.nextLong();
            }
        } {
            N = sc.nextInt();
            A = new long[N+1];
            B = new long[N];
            for(int i =0;i < N+1;i++){
                A[i] = sc.nextLong();
            }
            for(int i =0;i < N;i++){
                B[i] = sc.nextLong();
            }
        } Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) N = sc.nextInt() N sc.nextInt() sc.nextInt sc A = new long[N+1] A new long[N+1] N+1 N 1 B = new long[N] B new long[N] N for(int i =0;i < N+1;i++){
                A[i] = sc.nextLong();
            } int i =0; int i =0; i 0 i < N+1 i N+1 N 1 i++ i++ i {
                A[i] = sc.nextLong();
            } {
                A[i] = sc.nextLong();
            } A[i] = sc.nextLong() A[i] A i sc.nextLong() sc.nextLong sc for(int i =0;i < N;i++){
                B[i] = sc.nextLong();
            } int i =0; int i =0; i 0 i < N i N i++ i++ i {
                B[i] = sc.nextLong();
            } {
                B[i] = sc.nextLong();
            } B[i] = sc.nextLong() B[i] B i sc.nextLong() sc.nextLong sc long result = 0; result 0 for(int i =0;i < N;i++){
            if(B[i] > A[i]){
                result += A[i];
                long temp = A[i];
                A[i]-=temp;
                B[i] -=temp;
            }else{
                result += B[i];
                long temp = B[i];
                B[i]-=temp;
                A[i] -=temp;
            }
            if(B[i] > A[i+1]){
                result += A[i+1];
                long temp = A[i+1];
                A[i+1]-=temp;
                B[i] -=temp;
            }else{
                result += B[i];
                long temp = B[i];
                B[i]-=temp;
                A[i+1] -=temp;
            }
        } int i =0; int i =0; i 0 i < N i N i++ i++ i {
            if(B[i] > A[i]){
                result += A[i];
                long temp = A[i];
                A[i]-=temp;
                B[i] -=temp;
            }else{
                result += B[i];
                long temp = B[i];
                B[i]-=temp;
                A[i] -=temp;
            }
            if(B[i] > A[i+1]){
                result += A[i+1];
                long temp = A[i+1];
                A[i+1]-=temp;
                B[i] -=temp;
            }else{
                result += B[i];
                long temp = B[i];
                B[i]-=temp;
                A[i+1] -=temp;
            }
        } {
            if(B[i] > A[i]){
                result += A[i];
                long temp = A[i];
                A[i]-=temp;
                B[i] -=temp;
            }else{
                result += B[i];
                long temp = B[i];
                B[i]-=temp;
                A[i] -=temp;
            }
            if(B[i] > A[i+1]){
                result += A[i+1];
                long temp = A[i+1];
                A[i+1]-=temp;
                B[i] -=temp;
            }else{
                result += B[i];
                long temp = B[i];
                B[i]-=temp;
                A[i+1] -=temp;
            }
        } if(B[i] > A[i]){
                result += A[i];
                long temp = A[i];
                A[i]-=temp;
                B[i] -=temp;
            }else{
                result += B[i];
                long temp = B[i];
                B[i]-=temp;
                A[i] -=temp;
            } B[i] > A[i] B[i] B i A[i] A i {
                result += A[i];
                long temp = A[i];
                A[i]-=temp;
                B[i] -=temp;
            } result += A[i] result A[i] A i long temp = A[i]; temp A[i] A i A[i]-=temp A[i] A i temp B[i] -=temp B[i] B i temp {
                result += B[i];
                long temp = B[i];
                B[i]-=temp;
                A[i] -=temp;
            } result += B[i] result B[i] B i long temp = B[i]; temp B[i] B i B[i]-=temp B[i] B i temp A[i] -=temp A[i] A i temp if(B[i] > A[i+1]){
                result += A[i+1];
                long temp = A[i+1];
                A[i+1]-=temp;
                B[i] -=temp;
            }else{
                result += B[i];
                long temp = B[i];
                B[i]-=temp;
                A[i+1] -=temp;
            } B[i] > A[i+1] B[i] B i A[i+1] A i+1 i 1 {
                result += A[i+1];
                long temp = A[i+1];
                A[i+1]-=temp;
                B[i] -=temp;
            } result += A[i+1] result A[i+1] A i+1 i 1 long temp = A[i+1]; temp A[i+1] A i+1 i 1 A[i+1]-=temp A[i+1] A i+1 i 1 temp B[i] -=temp B[i] B i temp {
                result += B[i];
                long temp = B[i];
                B[i]-=temp;
                A[i+1] -=temp;
            } result += B[i] result B[i] B i long temp = B[i]; temp B[i] B i B[i]-=temp B[i] B i temp A[i+1] -=temp A[i+1] A i+1 i 1 temp System.out.println(result) System.out.println System.out System System.out result return; String[] args args public class Main {
    public static void debug(String str) {
        boolean debug = false;
        if (debug != false) {
            return;
        }
        System.out.println(str);
    }

    public static void main(String[] args) {

        int N;
        long A[];
        long B[];

        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            A = new long[N+1];
            B = new long[N];
            for(int i =0;i < N+1;i++){
                A[i] = sc.nextLong();
            }
            for(int i =0;i < N;i++){
                B[i] = sc.nextLong();
            }
        }
        long result = 0;
        for(int i =0;i < N;i++){
            if(B[i] > A[i]){
                result += A[i];
                long temp = A[i];
                A[i]-=temp;
                B[i] -=temp;
            }else{
                result += B[i];
                long temp = B[i];
                B[i]-=temp;
                A[i] -=temp;
            }
            if(B[i] > A[i+1]){
                result += A[i+1];
                long temp = A[i+1];
                A[i+1]-=temp;
                B[i] -=temp;
            }else{
                result += B[i];
                long temp = B[i];
                B[i]-=temp;
                A[i+1] -=temp;
            }
        }
        System.out.println(result);




        return;
    }
} public class Main {
    public static void debug(String str) {
        boolean debug = false;
        if (debug != false) {
            return;
        }
        System.out.println(str);
    }

    public static void main(String[] args) {

        int N;
        long A[];
        long B[];

        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            A = new long[N+1];
            B = new long[N];
            for(int i =0;i < N+1;i++){
                A[i] = sc.nextLong();
            }
            for(int i =0;i < N;i++){
                B[i] = sc.nextLong();
            }
        }
        long result = 0;
        for(int i =0;i < N;i++){
            if(B[i] > A[i]){
                result += A[i];
                long temp = A[i];
                A[i]-=temp;
                B[i] -=temp;
            }else{
                result += B[i];
                long temp = B[i];
                B[i]-=temp;
                A[i] -=temp;
            }
            if(B[i] > A[i+1]){
                result += A[i+1];
                long temp = A[i+1];
                A[i+1]-=temp;
                B[i] -=temp;
            }else{
                result += B[i];
                long temp = B[i];
                B[i]-=temp;
                A[i+1] -=temp;
            }
        }
        System.out.println(result);




        return;
    }
} Main
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        boolean debug = false;
        if (debug != false) {
            return;
        }
        System.out.println(str);
    }

    public static void main(String[] args) {

        int N;
        long A[];
        long B[];

        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            A = new long[N+1];
            B = new long[N];
            for(int i =0;i < N+1;i++){
                A[i] = sc.nextLong();
            }
            for(int i =0;i < N;i++){
                B[i] = sc.nextLong();
            }
        }
        long result = 0;
        for(int i =0;i < N;i++){
            if(B[i] > A[i]){
                result += A[i];
                long temp = A[i];
                A[i]-=temp;
                B[i] -=temp;
            }else{
                result += B[i];
                long temp = B[i];
                B[i]-=temp;
                A[i] -=temp;
            }
            if(B[i] > A[i+1]){
                result += A[i+1];
                long temp = A[i+1];
                A[i+1]-=temp;
                B[i] -=temp;
            }else{
                result += B[i];
                long temp = B[i];
                B[i]-=temp;
                A[i+1] -=temp;
            }
        }
        System.out.println(result);




        return;
    }
}
