import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = Integer.parseInt(s.nextLine());
        String[] in1 = s.nextLine().split(" ");
        String[] in2 = s.nextLine().split(" ");
        List<Integer> monsters = new ArrayList<Integer>();
        for(int i = 0;i<n+1;i++){
            monsters.add(Integer.parseInt(in1[i]));
        }
        long r = 0;
        for(int i = 0;i<n;i++){
            int power = Integer.parseInt(in2[i]);
            int targets1 = monsters.get(i);
            int targets2 = monsters.get(i+1);
            if(power - targets1 >= 0) {
                r += targets1;
                power -= targets1;
                if(power - targets2 >= 0){
                    r += targets2;
                    monsters.set(i+1,0);
                }else {
                    r += power;
                    monsters.set(i+1,targets2-power);
                }
            }else{
                r += power;
            }
        }
        System.out.println(r);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = Integer.parseInt(s.nextLine());
        String[] in1 = s.nextLine().split(" ");
        String[] in2 = s.nextLine().split(" ");
        List<Integer> monsters = new ArrayList<Integer>();
        for(int i = 0;i<n+1;i++){
            monsters.add(Integer.parseInt(in1[i]));
        }
        long r = 0;
        for(int i = 0;i<n;i++){
            int power = Integer.parseInt(in2[i]);
            int targets1 = monsters.get(i);
            int targets2 = monsters.get(i+1);
            if(power - targets1 >= 0) {
                r += targets1;
                power -= targets1;
                if(power - targets2 >= 0){
                    r += targets2;
                    monsters.set(i+1,0);
                }else {
                    r += power;
                    monsters.set(i+1,targets2-power);
                }
            }else{
                r += power;
            }
        }
        System.out.println(r);
    }
} Main public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = Integer.parseInt(s.nextLine());
        String[] in1 = s.nextLine().split(" ");
        String[] in2 = s.nextLine().split(" ");
        List<Integer> monsters = new ArrayList<Integer>();
        for(int i = 0;i<n+1;i++){
            monsters.add(Integer.parseInt(in1[i]));
        }
        long r = 0;
        for(int i = 0;i<n;i++){
            int power = Integer.parseInt(in2[i]);
            int targets1 = monsters.get(i);
            int targets2 = monsters.get(i+1);
            if(power - targets1 >= 0) {
                r += targets1;
                power -= targets1;
                if(power - targets2 >= 0){
                    r += targets2;
                    monsters.set(i+1,0);
                }else {
                    r += power;
                    monsters.set(i+1,targets2-power);
                }
            }else{
                r += power;
            }
        }
        System.out.println(r);
    } main {
        Scanner s = new Scanner(System.in);
        int n = Integer.parseInt(s.nextLine());
        String[] in1 = s.nextLine().split(" ");
        String[] in2 = s.nextLine().split(" ");
        List<Integer> monsters = new ArrayList<Integer>();
        for(int i = 0;i<n+1;i++){
            monsters.add(Integer.parseInt(in1[i]));
        }
        long r = 0;
        for(int i = 0;i<n;i++){
            int power = Integer.parseInt(in2[i]);
            int targets1 = monsters.get(i);
            int targets2 = monsters.get(i+1);
            if(power - targets1 >= 0) {
                r += targets1;
                power -= targets1;
                if(power - targets2 >= 0){
                    r += targets2;
                    monsters.set(i+1,0);
                }else {
                    r += power;
                    monsters.set(i+1,targets2-power);
                }
            }else{
                r += power;
            }
        }
        System.out.println(r);
    } Scanner s = new Scanner(System.in); s new Scanner(System.in) int n = Integer.parseInt(s.nextLine()); n Integer.parseInt(s.nextLine()) Integer.parseInt Integer s.nextLine() s.nextLine s String[] in1 = s.nextLine().split(" "); in1 s.nextLine().split(" ") s.nextLine().split s.nextLine() s.nextLine s " " String[] in2 = s.nextLine().split(" "); in2 s.nextLine().split(" ") s.nextLine().split s.nextLine() s.nextLine s " " List<Integer> monsters = new ArrayList<Integer>(); monsters new ArrayList<Integer>() for(int i = 0;i<n+1;i++){
            monsters.add(Integer.parseInt(in1[i]));
        } int i = 0; int i = 0; i 0 i<n+1 i n+1 n 1 i++ i++ i {
            monsters.add(Integer.parseInt(in1[i]));
        } {
            monsters.add(Integer.parseInt(in1[i]));
        } monsters.add(Integer.parseInt(in1[i])) monsters.add monsters Integer.parseInt(in1[i]) Integer.parseInt Integer in1[i] in1 i long r = 0; r 0 for(int i = 0;i<n;i++){
            int power = Integer.parseInt(in2[i]);
            int targets1 = monsters.get(i);
            int targets2 = monsters.get(i+1);
            if(power - targets1 >= 0) {
                r += targets1;
                power -= targets1;
                if(power - targets2 >= 0){
                    r += targets2;
                    monsters.set(i+1,0);
                }else {
                    r += power;
                    monsters.set(i+1,targets2-power);
                }
            }else{
                r += power;
            }
        } int i = 0; int i = 0; i 0 i<n i n i++ i++ i {
            int power = Integer.parseInt(in2[i]);
            int targets1 = monsters.get(i);
            int targets2 = monsters.get(i+1);
            if(power - targets1 >= 0) {
                r += targets1;
                power -= targets1;
                if(power - targets2 >= 0){
                    r += targets2;
                    monsters.set(i+1,0);
                }else {
                    r += power;
                    monsters.set(i+1,targets2-power);
                }
            }else{
                r += power;
            }
        } {
            int power = Integer.parseInt(in2[i]);
            int targets1 = monsters.get(i);
            int targets2 = monsters.get(i+1);
            if(power - targets1 >= 0) {
                r += targets1;
                power -= targets1;
                if(power - targets2 >= 0){
                    r += targets2;
                    monsters.set(i+1,0);
                }else {
                    r += power;
                    monsters.set(i+1,targets2-power);
                }
            }else{
                r += power;
            }
        } int power = Integer.parseInt(in2[i]); power Integer.parseInt(in2[i]) Integer.parseInt Integer in2[i] in2 i int targets1 = monsters.get(i); targets1 monsters.get(i) monsters.get monsters i int targets2 = monsters.get(i+1); targets2 monsters.get(i+1) monsters.get monsters i+1 i 1 if(power - targets1 >= 0) {
                r += targets1;
                power -= targets1;
                if(power - targets2 >= 0){
                    r += targets2;
                    monsters.set(i+1,0);
                }else {
                    r += power;
                    monsters.set(i+1,targets2-power);
                }
            }else{
                r += power;
            } power - targets1 >= 0 power - targets1 power targets1 0 {
                r += targets1;
                power -= targets1;
                if(power - targets2 >= 0){
                    r += targets2;
                    monsters.set(i+1,0);
                }else {
                    r += power;
                    monsters.set(i+1,targets2-power);
                }
            } r += targets1 r targets1 power -= targets1 power targets1 if(power - targets2 >= 0){
                    r += targets2;
                    monsters.set(i+1,0);
                }else {
                    r += power;
                    monsters.set(i+1,targets2-power);
                } power - targets2 >= 0 power - targets2 power targets2 0 {
                    r += targets2;
                    monsters.set(i+1,0);
                } r += targets2 r targets2 monsters.set(i+1,0) monsters.set monsters i+1 i 1 0 {
                    r += power;
                    monsters.set(i+1,targets2-power);
                } r += power r power monsters.set(i+1,targets2-power) monsters.set monsters i+1 i 1 targets2-power targets2 power {
                r += power;
            } r += power r power System.out.println(r) System.out.println System.out System System.out r String[] args args public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = Integer.parseInt(s.nextLine());
        String[] in1 = s.nextLine().split(" ");
        String[] in2 = s.nextLine().split(" ");
        List<Integer> monsters = new ArrayList<Integer>();
        for(int i = 0;i<n+1;i++){
            monsters.add(Integer.parseInt(in1[i]));
        }
        long r = 0;
        for(int i = 0;i<n;i++){
            int power = Integer.parseInt(in2[i]);
            int targets1 = monsters.get(i);
            int targets2 = monsters.get(i+1);
            if(power - targets1 >= 0) {
                r += targets1;
                power -= targets1;
                if(power - targets2 >= 0){
                    r += targets2;
                    monsters.set(i+1,0);
                }else {
                    r += power;
                    monsters.set(i+1,targets2-power);
                }
            }else{
                r += power;
            }
        }
        System.out.println(r);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = Integer.parseInt(s.nextLine());
        String[] in1 = s.nextLine().split(" ");
        String[] in2 = s.nextLine().split(" ");
        List<Integer> monsters = new ArrayList<Integer>();
        for(int i = 0;i<n+1;i++){
            monsters.add(Integer.parseInt(in1[i]));
        }
        long r = 0;
        for(int i = 0;i<n;i++){
            int power = Integer.parseInt(in2[i]);
            int targets1 = monsters.get(i);
            int targets2 = monsters.get(i+1);
            if(power - targets1 >= 0) {
                r += targets1;
                power -= targets1;
                if(power - targets2 >= 0){
                    r += targets2;
                    monsters.set(i+1,0);
                }else {
                    r += power;
                    monsters.set(i+1,targets2-power);
                }
            }else{
                r += power;
            }
        }
        System.out.println(r);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = Integer.parseInt(s.nextLine());
        String[] in1 = s.nextLine().split(" ");
        String[] in2 = s.nextLine().split(" ");
        List<Integer> monsters = new ArrayList<Integer>();
        for(int i = 0;i<n+1;i++){
            monsters.add(Integer.parseInt(in1[i]));
        }
        long r = 0;
        for(int i = 0;i<n;i++){
            int power = Integer.parseInt(in2[i]);
            int targets1 = monsters.get(i);
            int targets2 = monsters.get(i+1);
            if(power - targets1 >= 0) {
                r += targets1;
                power -= targets1;
                if(power - targets2 >= 0){
                    r += targets2;
                    monsters.set(i+1,0);
                }else {
                    r += power;
                    monsters.set(i+1,targets2-power);
                }
            }else{
                r += power;
            }
        }
        System.out.println(r);
    }
}