import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n+1];
        int[] b = new int[n];
        for(int i=0;i<n+1;i++){
            a[i] = Integer.parseInt(sc.next());
        }
        for(int i=0;i<n;i++){
            b[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        long monster = 0;
        for(int i=n-1;i>=0;i--){
            if(b[i] > a[i+1]){
                monster+=a[i+1];
                b[i]-=a[i+1];
                monster+=Math.min(a[i],b[i]);
                a[i]-=Math.min(a[i],b[i]);
            }else{
                monster+=b[i];
                a[i+1]-=b[i];
            }
        }
        System.out.println(monster);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n+1];
        int[] b = new int[n];
        for(int i=0;i<n+1;i++){
            a[i] = Integer.parseInt(sc.next());
        }
        for(int i=0;i<n;i++){
            b[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        long monster = 0;
        for(int i=n-1;i>=0;i--){
            if(b[i] > a[i+1]){
                monster+=a[i+1];
                b[i]-=a[i+1];
                monster+=Math.min(a[i],b[i]);
                a[i]-=Math.min(a[i],b[i]);
            }else{
                monster+=b[i];
                a[i+1]-=b[i];
            }
        }
        System.out.println(monster);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n+1];
        int[] b = new int[n];
        for(int i=0;i<n+1;i++){
            a[i] = Integer.parseInt(sc.next());
        }
        for(int i=0;i<n;i++){
            b[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        long monster = 0;
        for(int i=n-1;i>=0;i--){
            if(b[i] > a[i+1]){
                monster+=a[i+1];
                b[i]-=a[i+1];
                monster+=Math.min(a[i],b[i]);
                a[i]-=Math.min(a[i],b[i]);
            }else{
                monster+=b[i];
                a[i+1]-=b[i];
            }
        }
        System.out.println(monster);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n+1];
        int[] b = new int[n];
        for(int i=0;i<n+1;i++){
            a[i] = Integer.parseInt(sc.next());
        }
        for(int i=0;i<n;i++){
            b[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        long monster = 0;
        for(int i=n-1;i>=0;i--){
            if(b[i] > a[i+1]){
                monster+=a[i+1];
                b[i]-=a[i+1];
                monster+=Math.min(a[i],b[i]);
                a[i]-=Math.min(a[i],b[i]);
            }else{
                monster+=b[i];
                a[i+1]-=b[i];
            }
        }
        System.out.println(monster);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] a = new int[n+1]; a new int[n+1] n+1 n 1 int[] b = new int[n]; b new int[n] n for(int i=0;i<n+1;i++){
            a[i] = Integer.parseInt(sc.next());
        } int i=0; int i=0; i 0 i<n+1 i n+1 n 1 i++ i++ i {
            a[i] = Integer.parseInt(sc.next());
        } {
            a[i] = Integer.parseInt(sc.next());
        } a[i] = Integer.parseInt(sc.next()) a[i] a i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc for(int i=0;i<n;i++){
            b[i] = Integer.parseInt(sc.next());
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            b[i] = Integer.parseInt(sc.next());
        } {
            b[i] = Integer.parseInt(sc.next());
        } b[i] = Integer.parseInt(sc.next()) b[i] b i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc sc.close() sc.close sc long monster = 0; monster 0 for(int i=n-1;i>=0;i--){
            if(b[i] > a[i+1]){
                monster+=a[i+1];
                b[i]-=a[i+1];
                monster+=Math.min(a[i],b[i]);
                a[i]-=Math.min(a[i],b[i]);
            }else{
                monster+=b[i];
                a[i+1]-=b[i];
            }
        } int i=n-1; int i=n-1; i n-1 n 1 i>=0 i 0 i-- i-- i {
            if(b[i] > a[i+1]){
                monster+=a[i+1];
                b[i]-=a[i+1];
                monster+=Math.min(a[i],b[i]);
                a[i]-=Math.min(a[i],b[i]);
            }else{
                monster+=b[i];
                a[i+1]-=b[i];
            }
        } {
            if(b[i] > a[i+1]){
                monster+=a[i+1];
                b[i]-=a[i+1];
                monster+=Math.min(a[i],b[i]);
                a[i]-=Math.min(a[i],b[i]);
            }else{
                monster+=b[i];
                a[i+1]-=b[i];
            }
        } if(b[i] > a[i+1]){
                monster+=a[i+1];
                b[i]-=a[i+1];
                monster+=Math.min(a[i],b[i]);
                a[i]-=Math.min(a[i],b[i]);
            }else{
                monster+=b[i];
                a[i+1]-=b[i];
            } b[i] > a[i+1] b[i] b i a[i+1] a i+1 i 1 {
                monster+=a[i+1];
                b[i]-=a[i+1];
                monster+=Math.min(a[i],b[i]);
                a[i]-=Math.min(a[i],b[i]);
            } monster+=a[i+1] monster 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 monster+=Math.min(a[i],b[i]) monster Math.min(a[i],b[i]) Math.min Math a[i] a i b[i] b i a[i]-=Math.min(a[i],b[i]) a[i] a i Math.min(a[i],b[i]) Math.min Math a[i] a i b[i] b i {
                monster+=b[i];
                a[i+1]-=b[i];
            } monster+=b[i] monster b[i] b i a[i+1]-=b[i] a[i+1] a i+1 i 1 b[i] b i System.out.println(monster) System.out.println System.out System System.out monster String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n+1];
        int[] b = new int[n];
        for(int i=0;i<n+1;i++){
            a[i] = Integer.parseInt(sc.next());
        }
        for(int i=0;i<n;i++){
            b[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        long monster = 0;
        for(int i=n-1;i>=0;i--){
            if(b[i] > a[i+1]){
                monster+=a[i+1];
                b[i]-=a[i+1];
                monster+=Math.min(a[i],b[i]);
                a[i]-=Math.min(a[i],b[i]);
            }else{
                monster+=b[i];
                a[i+1]-=b[i];
            }
        }
        System.out.println(monster);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n+1];
        int[] b = new int[n];
        for(int i=0;i<n+1;i++){
            a[i] = Integer.parseInt(sc.next());
        }
        for(int i=0;i<n;i++){
            b[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        long monster = 0;
        for(int i=n-1;i>=0;i--){
            if(b[i] > a[i+1]){
                monster+=a[i+1];
                b[i]-=a[i+1];
                monster+=Math.min(a[i],b[i]);
                a[i]-=Math.min(a[i],b[i]);
            }else{
                monster+=b[i];
                a[i+1]-=b[i];
            }
        }
        System.out.println(monster);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n+1];
        int[] b = new int[n];
        for(int i=0;i<n+1;i++){
            a[i] = Integer.parseInt(sc.next());
        }
        for(int i=0;i<n;i++){
            b[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        long monster = 0;
        for(int i=n-1;i>=0;i--){
            if(b[i] > a[i+1]){
                monster+=a[i+1];
                b[i]-=a[i+1];
                monster+=Math.min(a[i],b[i]);
                a[i]-=Math.min(a[i],b[i]);
            }else{
                monster+=b[i];
                a[i+1]-=b[i];
            }
        }
        System.out.println(monster);
    }
}
