import java.util.*;

class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] A = new int[N + 1];
        int[] B = new int[N];
        long ans = 0;
 
        for(int i=0; i<=N; i++){
            A[i] = sc.nextInt();
        }
        for(int i=0; i<N; i++){
            B[i] = sc.nextInt();
        }
 
        for(int i=0; i<N; i++){
            int x = Math.min(A[i], B[i]);
            ans += x;
            B[i] -= x;
            int y = Math.min(A[i + 1], B[i]);
            ans += y;
            A[i + 1] -= y;
        }
        System.out.println(ans);
    }
} import java.util.*; util.* java class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] A = new int[N + 1];
        int[] B = new int[N];
        long ans = 0;
 
        for(int i=0; i<=N; i++){
            A[i] = sc.nextInt();
        }
        for(int i=0; i<N; i++){
            B[i] = sc.nextInt();
        }
 
        for(int i=0; i<N; i++){
            int x = Math.min(A[i], B[i]);
            ans += x;
            B[i] -= x;
            int y = Math.min(A[i + 1], B[i]);
            ans += y;
            A[i + 1] -= y;
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] A = new int[N + 1];
        int[] B = new int[N];
        long ans = 0;
 
        for(int i=0; i<=N; i++){
            A[i] = sc.nextInt();
        }
        for(int i=0; i<N; i++){
            B[i] = sc.nextInt();
        }
 
        for(int i=0; i<N; i++){
            int x = Math.min(A[i], B[i]);
            ans += x;
            B[i] -= x;
            int y = Math.min(A[i + 1], B[i]);
            ans += y;
            A[i + 1] -= y;
        }
        System.out.println(ans);
    } main {
        
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] A = new int[N + 1];
        int[] B = new int[N];
        long ans = 0;
 
        for(int i=0; i<=N; i++){
            A[i] = sc.nextInt();
        }
        for(int i=0; i<N; i++){
            B[i] = sc.nextInt();
        }
 
        for(int i=0; i<N; i++){
            int x = Math.min(A[i], B[i]);
            ans += x;
            B[i] -= x;
            int y = Math.min(A[i + 1], B[i]);
            ans += y;
            A[i + 1] -= y;
        }
        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt 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 long ans = 0; ans 0 for(int i=0; i<=N; i++){
            A[i] = sc.nextInt();
        } int i=0; int i=0; i 0 i<=N i N i++ i++ i {
            A[i] = sc.nextInt();
        } {
            A[i] = sc.nextInt();
        } A[i] = sc.nextInt() A[i] A i sc.nextInt() sc.nextInt sc for(int i=0; i<N; i++){
            B[i] = sc.nextInt();
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            B[i] = sc.nextInt();
        } {
            B[i] = sc.nextInt();
        } B[i] = sc.nextInt() B[i] B i sc.nextInt() sc.nextInt sc for(int i=0; i<N; i++){
            int x = Math.min(A[i], B[i]);
            ans += x;
            B[i] -= x;
            int y = Math.min(A[i + 1], B[i]);
            ans += y;
            A[i + 1] -= y;
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            int x = Math.min(A[i], B[i]);
            ans += x;
            B[i] -= x;
            int y = Math.min(A[i + 1], B[i]);
            ans += y;
            A[i + 1] -= y;
        } {
            int x = Math.min(A[i], B[i]);
            ans += x;
            B[i] -= x;
            int y = Math.min(A[i + 1], B[i]);
            ans += y;
            A[i + 1] -= y;
        } int x = Math.min(A[i], B[i]); x Math.min(A[i], B[i]) Math.min Math A[i] A i B[i] B i ans += x ans x B[i] -= x B[i] B i x int y = Math.min(A[i + 1], B[i]); y Math.min(A[i + 1], B[i]) Math.min Math A[i + 1] A i + 1 i 1 B[i] B i ans += y ans y A[i + 1] -= y A[i + 1] A i + 1 i 1 y System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*;

class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] A = new int[N + 1];
        int[] B = new int[N];
        long ans = 0;
 
        for(int i=0; i<=N; i++){
            A[i] = sc.nextInt();
        }
        for(int i=0; i<N; i++){
            B[i] = sc.nextInt();
        }
 
        for(int i=0; i<N; i++){
            int x = Math.min(A[i], B[i]);
            ans += x;
            B[i] -= x;
            int y = Math.min(A[i + 1], B[i]);
            ans += y;
            A[i + 1] -= y;
        }
        System.out.println(ans);
    }
}