import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n + 1];
        long[] 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 sum = 0, residue = 0, ability;
        for (int i = 0; i < n + 1; i++) {
            if (i != n) {
                ability = b[i] + residue;
                residue = Math.min(ability - a[i], b[i]);
                residue = Math.max(residue, 0);
            } else {
                ability = residue;
            }
            
            if (a[i] < ability) {
                sum += a[i];
            } else {
                sum += ability;
            }
        }
        System.out.println(sum);
    }
    
} import java.util.*; util.* java import java.lang.*; lang.* java public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n + 1];
        long[] 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 sum = 0, residue = 0, ability;
        for (int i = 0; i < n + 1; i++) {
            if (i != n) {
                ability = b[i] + residue;
                residue = Math.min(ability - a[i], b[i]);
                residue = Math.max(residue, 0);
            } else {
                ability = residue;
            }
            
            if (a[i] < ability) {
                sum += a[i];
            } else {
                sum += ability;
            }
        }
        System.out.println(sum);
    }
    
} Main public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n + 1];
        long[] 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 sum = 0, residue = 0, ability;
        for (int i = 0; i < n + 1; i++) {
            if (i != n) {
                ability = b[i] + residue;
                residue = Math.min(ability - a[i], b[i]);
                residue = Math.max(residue, 0);
            } else {
                ability = residue;
            }
            
            if (a[i] < ability) {
                sum += a[i];
            } else {
                sum += ability;
            }
        }
        System.out.println(sum);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n + 1];
        long[] 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 sum = 0, residue = 0, ability;
        for (int i = 0; i < n + 1; i++) {
            if (i != n) {
                ability = b[i] + residue;
                residue = Math.min(ability - a[i], b[i]);
                residue = Math.max(residue, 0);
            } else {
                ability = residue;
            }
            
            if (a[i] < ability) {
                sum += a[i];
            } else {
                sum += ability;
            }
        }
        System.out.println(sum);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc 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] = 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 sum = 0 sum 0 residue = 0 residue 0 ability; ability for (int i = 0; i < n + 1; i++) {
            if (i != n) {
                ability = b[i] + residue;
                residue = Math.min(ability - a[i], b[i]);
                residue = Math.max(residue, 0);
            } else {
                ability = residue;
            }
            
            if (a[i] < ability) {
                sum += a[i];
            } else {
                sum += ability;
            }
        } int i = 0; int i = 0; i 0 i < n + 1 i n + 1 n 1 i++ i++ i {
            if (i != n) {
                ability = b[i] + residue;
                residue = Math.min(ability - a[i], b[i]);
                residue = Math.max(residue, 0);
            } else {
                ability = residue;
            }
            
            if (a[i] < ability) {
                sum += a[i];
            } else {
                sum += ability;
            }
        } {
            if (i != n) {
                ability = b[i] + residue;
                residue = Math.min(ability - a[i], b[i]);
                residue = Math.max(residue, 0);
            } else {
                ability = residue;
            }
            
            if (a[i] < ability) {
                sum += a[i];
            } else {
                sum += ability;
            }
        } if (i != n) {
                ability = b[i] + residue;
                residue = Math.min(ability - a[i], b[i]);
                residue = Math.max(residue, 0);
            } else {
                ability = residue;
            } i != n i n {
                ability = b[i] + residue;
                residue = Math.min(ability - a[i], b[i]);
                residue = Math.max(residue, 0);
            } ability = b[i] + residue ability b[i] + residue b[i] b i residue residue = Math.min(ability - a[i], b[i]) residue Math.min(ability - a[i], b[i]) Math.min Math ability - a[i] ability a[i] a i b[i] b i residue = Math.max(residue, 0) residue Math.max(residue, 0) Math.max Math residue 0 {
                ability = residue;
            } ability = residue ability residue if (a[i] < ability) {
                sum += a[i];
            } else {
                sum += ability;
            } a[i] < ability a[i] a i ability {
                sum += a[i];
            } sum += a[i] sum a[i] a i {
                sum += ability;
            } sum += ability sum ability System.out.println(sum) System.out.println System.out System System.out sum String args[] args public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n + 1];
        long[] 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 sum = 0, residue = 0, ability;
        for (int i = 0; i < n + 1; i++) {
            if (i != n) {
                ability = b[i] + residue;
                residue = Math.min(ability - a[i], b[i]);
                residue = Math.max(residue, 0);
            } else {
                ability = residue;
            }
            
            if (a[i] < ability) {
                sum += a[i];
            } else {
                sum += ability;
            }
        }
        System.out.println(sum);
    }
    
} public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n + 1];
        long[] 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 sum = 0, residue = 0, ability;
        for (int i = 0; i < n + 1; i++) {
            if (i != n) {
                ability = b[i] + residue;
                residue = Math.min(ability - a[i], b[i]);
                residue = Math.max(residue, 0);
            } else {
                ability = residue;
            }
            
            if (a[i] < ability) {
                sum += a[i];
            } else {
                sum += ability;
            }
        }
        System.out.println(sum);
    }
    
} Main
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n + 1];
        long[] 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 sum = 0, residue = 0, ability;
        for (int i = 0; i < n + 1; i++) {
            if (i != n) {
                ability = b[i] + residue;
                residue = Math.min(ability - a[i], b[i]);
                residue = Math.max(residue, 0);
            } else {
                ability = residue;
            }
            
            if (a[i] < ability) {
                sum += a[i];
            } else {
                sum += ability;
            }
        }
        System.out.println(sum);
    }
    
}