import java.util.*;
import java.math.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        long[] cities = new long[num+1];
        long[] heroes = new long[num];
        for(int i=0;i<num+1;i++)
            cities[i]=sc.nextLong();
        for(int i=0;i<num;i++)
            heroes[i]=sc.nextLong();
        long count=0;
        long x=0;
        for(int i=0;i<num;i++)
        {
            x = Math.min(cities[i], heroes[i]);
            heroes[i] -= x;
            count += x;
            x = Math.min(cities[i+1], heroes[i]);
            cities[i+1] -= x;
            count += x;
        }
        System.out.println(count);
    }
} import java.util.*; util.* java import java.math.*; math.* java class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        long[] cities = new long[num+1];
        long[] heroes = new long[num];
        for(int i=0;i<num+1;i++)
            cities[i]=sc.nextLong();
        for(int i=0;i<num;i++)
            heroes[i]=sc.nextLong();
        long count=0;
        long x=0;
        for(int i=0;i<num;i++)
        {
            x = Math.min(cities[i], heroes[i]);
            heroes[i] -= x;
            count += x;
            x = Math.min(cities[i+1], heroes[i]);
            cities[i+1] -= x;
            count += x;
        }
        System.out.println(count);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        long[] cities = new long[num+1];
        long[] heroes = new long[num];
        for(int i=0;i<num+1;i++)
            cities[i]=sc.nextLong();
        for(int i=0;i<num;i++)
            heroes[i]=sc.nextLong();
        long count=0;
        long x=0;
        for(int i=0;i<num;i++)
        {
            x = Math.min(cities[i], heroes[i]);
            heroes[i] -= x;
            count += x;
            x = Math.min(cities[i+1], heroes[i]);
            cities[i+1] -= x;
            count += x;
        }
        System.out.println(count);
    } main {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        long[] cities = new long[num+1];
        long[] heroes = new long[num];
        for(int i=0;i<num+1;i++)
            cities[i]=sc.nextLong();
        for(int i=0;i<num;i++)
            heroes[i]=sc.nextLong();
        long count=0;
        long x=0;
        for(int i=0;i<num;i++)
        {
            x = Math.min(cities[i], heroes[i]);
            heroes[i] -= x;
            count += x;
            x = Math.min(cities[i+1], heroes[i]);
            cities[i+1] -= x;
            count += x;
        }
        System.out.println(count);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int num = sc.nextInt(); num sc.nextInt() sc.nextInt sc long[] cities = new long[num+1]; cities new long[num+1] num+1 num 1 long[] heroes = new long[num]; heroes new long[num] num for(int i=0;i<num+1;i++)
            cities[i]=sc.nextLong(); int i=0; int i=0; i 0 i<num+1 i num+1 num 1 i++ i++ i cities[i]=sc.nextLong(); cities[i]=sc.nextLong() cities[i] cities i sc.nextLong() sc.nextLong sc for(int i=0;i<num;i++)
            heroes[i]=sc.nextLong(); int i=0; int i=0; i 0 i<num i num i++ i++ i heroes[i]=sc.nextLong(); heroes[i]=sc.nextLong() heroes[i] heroes i sc.nextLong() sc.nextLong sc long count=0; count 0 long x=0; x 0 for(int i=0;i<num;i++)
        {
            x = Math.min(cities[i], heroes[i]);
            heroes[i] -= x;
            count += x;
            x = Math.min(cities[i+1], heroes[i]);
            cities[i+1] -= x;
            count += x;
        } int i=0; int i=0; i 0 i<num i num i++ i++ i {
            x = Math.min(cities[i], heroes[i]);
            heroes[i] -= x;
            count += x;
            x = Math.min(cities[i+1], heroes[i]);
            cities[i+1] -= x;
            count += x;
        } {
            x = Math.min(cities[i], heroes[i]);
            heroes[i] -= x;
            count += x;
            x = Math.min(cities[i+1], heroes[i]);
            cities[i+1] -= x;
            count += x;
        } x = Math.min(cities[i], heroes[i]) x Math.min(cities[i], heroes[i]) Math.min Math cities[i] cities i heroes[i] heroes i heroes[i] -= x heroes[i] heroes i x count += x count x x = Math.min(cities[i+1], heroes[i]) x Math.min(cities[i+1], heroes[i]) Math.min Math cities[i+1] cities i+1 i 1 heroes[i] heroes i cities[i+1] -= x cities[i+1] cities i+1 i 1 x count += x count x System.out.println(count) System.out.println System.out System System.out count String[] args args
import java.util.*;
import java.math.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        long[] cities = new long[num+1];
        long[] heroes = new long[num];
        for(int i=0;i<num+1;i++)
            cities[i]=sc.nextLong();
        for(int i=0;i<num;i++)
            heroes[i]=sc.nextLong();
        long count=0;
        long x=0;
        for(int i=0;i<num;i++)
        {
            x = Math.min(cities[i], heroes[i]);
            heroes[i] -= x;
            count += x;
            x = Math.min(cities[i+1], heroes[i]);
            cities[i+1] -= x;
            count += x;
        }
        System.out.println(count);
    }
}