import java.util.*;

public class Main {
    static long mod = 1000000007;

    public static long gcd(long a, long b) {
        if (a == 0) {
            return b;
        } else if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] lis_a = new long[n+1];
        long[] lis_b = new long[n];

        for (int i = 0; i < n + 1; ++i) {
            lis_a[i] = sc.nextLong();
        }
        for (int i = 0; i < n; ++i) {
            lis_b[i] = sc.nextLong();
        }

        long sum = 0;
        for (int i = n; i >= 0; --i) {
            if (i == n) {
                long x = Math.min(lis_a[i], lis_b[i - 1]);
                sum += x;
                lis_b[i - 1] -= x;
            } else if (i == 0) {
                long x = Math.min(lis_a[i], lis_b[i]);
                sum += x;
                lis_b[i] -= x;
            } else {
                long x = Math.min(lis_a[i], lis_b[i] + lis_b[i - 1]);
                sum += x;
                if (lis_b[i] >= x) {
                    lis_b[i] -= x;
                } else {
                    lis_b[i - 1] -= x - lis_b[i];
                    lis_b[i] = 0;
                }
            }
        }

        System.out.println(sum);
    }
} import java.util.*; util.* java public class Main {
    static long mod = 1000000007;

    public static long gcd(long a, long b) {
        if (a == 0) {
            return b;
        } else if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] lis_a = new long[n+1];
        long[] lis_b = new long[n];

        for (int i = 0; i < n + 1; ++i) {
            lis_a[i] = sc.nextLong();
        }
        for (int i = 0; i < n; ++i) {
            lis_b[i] = sc.nextLong();
        }

        long sum = 0;
        for (int i = n; i >= 0; --i) {
            if (i == n) {
                long x = Math.min(lis_a[i], lis_b[i - 1]);
                sum += x;
                lis_b[i - 1] -= x;
            } else if (i == 0) {
                long x = Math.min(lis_a[i], lis_b[i]);
                sum += x;
                lis_b[i] -= x;
            } else {
                long x = Math.min(lis_a[i], lis_b[i] + lis_b[i - 1]);
                sum += x;
                if (lis_b[i] >= x) {
                    lis_b[i] -= x;
                } else {
                    lis_b[i - 1] -= x - lis_b[i];
                    lis_b[i] = 0;
                }
            }
        }

        System.out.println(sum);
    }
} Main static long mod = 1000000007; mod 1000000007 public static long gcd(long a, long b) {
        if (a == 0) {
            return b;
        } else if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    } gcd {
        if (a == 0) {
            return b;
        } else if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    } if (a == 0) {
            return b;
        } else if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        } a == 0 a 0 {
            return b;
        } return b; b if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        } b == 0 b 0 {
            return a;
        } return a; a {
            return gcd(b, a % b);
        } return gcd(b, a % b); gcd(b, a % b) gcd b a % b a b long a a long b b public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] lis_a = new long[n+1];
        long[] lis_b = new long[n];

        for (int i = 0; i < n + 1; ++i) {
            lis_a[i] = sc.nextLong();
        }
        for (int i = 0; i < n; ++i) {
            lis_b[i] = sc.nextLong();
        }

        long sum = 0;
        for (int i = n; i >= 0; --i) {
            if (i == n) {
                long x = Math.min(lis_a[i], lis_b[i - 1]);
                sum += x;
                lis_b[i - 1] -= x;
            } else if (i == 0) {
                long x = Math.min(lis_a[i], lis_b[i]);
                sum += x;
                lis_b[i] -= x;
            } else {
                long x = Math.min(lis_a[i], lis_b[i] + lis_b[i - 1]);
                sum += x;
                if (lis_b[i] >= x) {
                    lis_b[i] -= x;
                } else {
                    lis_b[i - 1] -= x - lis_b[i];
                    lis_b[i] = 0;
                }
            }
        }

        System.out.println(sum);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] lis_a = new long[n+1];
        long[] lis_b = new long[n];

        for (int i = 0; i < n + 1; ++i) {
            lis_a[i] = sc.nextLong();
        }
        for (int i = 0; i < n; ++i) {
            lis_b[i] = sc.nextLong();
        }

        long sum = 0;
        for (int i = n; i >= 0; --i) {
            if (i == n) {
                long x = Math.min(lis_a[i], lis_b[i - 1]);
                sum += x;
                lis_b[i - 1] -= x;
            } else if (i == 0) {
                long x = Math.min(lis_a[i], lis_b[i]);
                sum += x;
                lis_b[i] -= x;
            } else {
                long x = Math.min(lis_a[i], lis_b[i] + lis_b[i - 1]);
                sum += x;
                if (lis_b[i] >= x) {
                    lis_b[i] -= x;
                } else {
                    lis_b[i - 1] -= x - lis_b[i];
                    lis_b[i] = 0;
                }
            }
        }

        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[] lis_a = new long[n+1]; lis_a new long[n+1] n+1 n 1 long[] lis_b = new long[n]; lis_b new long[n] n for (int i = 0; i < n + 1; ++i) {
            lis_a[i] = sc.nextLong();
        } int i = 0; int i = 0; i 0 i < n + 1 i n + 1 n 1 ++i ++i i {
            lis_a[i] = sc.nextLong();
        } {
            lis_a[i] = sc.nextLong();
        } lis_a[i] = sc.nextLong() lis_a[i] lis_a i sc.nextLong() sc.nextLong sc for (int i = 0; i < n; ++i) {
            lis_b[i] = sc.nextLong();
        } int i = 0; int i = 0; i 0 i < n i n ++i ++i i {
            lis_b[i] = sc.nextLong();
        } {
            lis_b[i] = sc.nextLong();
        } lis_b[i] = sc.nextLong() lis_b[i] lis_b i sc.nextLong() sc.nextLong sc long sum = 0; sum 0 for (int i = n; i >= 0; --i) {
            if (i == n) {
                long x = Math.min(lis_a[i], lis_b[i - 1]);
                sum += x;
                lis_b[i - 1] -= x;
            } else if (i == 0) {
                long x = Math.min(lis_a[i], lis_b[i]);
                sum += x;
                lis_b[i] -= x;
            } else {
                long x = Math.min(lis_a[i], lis_b[i] + lis_b[i - 1]);
                sum += x;
                if (lis_b[i] >= x) {
                    lis_b[i] -= x;
                } else {
                    lis_b[i - 1] -= x - lis_b[i];
                    lis_b[i] = 0;
                }
            }
        } int i = n; int i = n; i n i >= 0 i 0 --i --i i {
            if (i == n) {
                long x = Math.min(lis_a[i], lis_b[i - 1]);
                sum += x;
                lis_b[i - 1] -= x;
            } else if (i == 0) {
                long x = Math.min(lis_a[i], lis_b[i]);
                sum += x;
                lis_b[i] -= x;
            } else {
                long x = Math.min(lis_a[i], lis_b[i] + lis_b[i - 1]);
                sum += x;
                if (lis_b[i] >= x) {
                    lis_b[i] -= x;
                } else {
                    lis_b[i - 1] -= x - lis_b[i];
                    lis_b[i] = 0;
                }
            }
        } {
            if (i == n) {
                long x = Math.min(lis_a[i], lis_b[i - 1]);
                sum += x;
                lis_b[i - 1] -= x;
            } else if (i == 0) {
                long x = Math.min(lis_a[i], lis_b[i]);
                sum += x;
                lis_b[i] -= x;
            } else {
                long x = Math.min(lis_a[i], lis_b[i] + lis_b[i - 1]);
                sum += x;
                if (lis_b[i] >= x) {
                    lis_b[i] -= x;
                } else {
                    lis_b[i - 1] -= x - lis_b[i];
                    lis_b[i] = 0;
                }
            }
        } if (i == n) {
                long x = Math.min(lis_a[i], lis_b[i - 1]);
                sum += x;
                lis_b[i - 1] -= x;
            } else if (i == 0) {
                long x = Math.min(lis_a[i], lis_b[i]);
                sum += x;
                lis_b[i] -= x;
            } else {
                long x = Math.min(lis_a[i], lis_b[i] + lis_b[i - 1]);
                sum += x;
                if (lis_b[i] >= x) {
                    lis_b[i] -= x;
                } else {
                    lis_b[i - 1] -= x - lis_b[i];
                    lis_b[i] = 0;
                }
            } i == n i n {
                long x = Math.min(lis_a[i], lis_b[i - 1]);
                sum += x;
                lis_b[i - 1] -= x;
            } long x = Math.min(lis_a[i], lis_b[i - 1]); x Math.min(lis_a[i], lis_b[i - 1]) Math.min Math lis_a[i] lis_a i lis_b[i - 1] lis_b i - 1 i 1 sum += x sum x lis_b[i - 1] -= x lis_b[i - 1] lis_b i - 1 i 1 x if (i == 0) {
                long x = Math.min(lis_a[i], lis_b[i]);
                sum += x;
                lis_b[i] -= x;
            } else {
                long x = Math.min(lis_a[i], lis_b[i] + lis_b[i - 1]);
                sum += x;
                if (lis_b[i] >= x) {
                    lis_b[i] -= x;
                } else {
                    lis_b[i - 1] -= x - lis_b[i];
                    lis_b[i] = 0;
                }
            } i == 0 i 0 {
                long x = Math.min(lis_a[i], lis_b[i]);
                sum += x;
                lis_b[i] -= x;
            } long x = Math.min(lis_a[i], lis_b[i]); x Math.min(lis_a[i], lis_b[i]) Math.min Math lis_a[i] lis_a i lis_b[i] lis_b i sum += x sum x lis_b[i] -= x lis_b[i] lis_b i x {
                long x = Math.min(lis_a[i], lis_b[i] + lis_b[i - 1]);
                sum += x;
                if (lis_b[i] >= x) {
                    lis_b[i] -= x;
                } else {
                    lis_b[i - 1] -= x - lis_b[i];
                    lis_b[i] = 0;
                }
            } long x = Math.min(lis_a[i], lis_b[i] + lis_b[i - 1]); x Math.min(lis_a[i], lis_b[i] + lis_b[i - 1]) Math.min Math lis_a[i] lis_a i lis_b[i] + lis_b[i - 1] lis_b[i] lis_b i lis_b[i - 1] lis_b i - 1 i 1 sum += x sum x if (lis_b[i] >= x) {
                    lis_b[i] -= x;
                } else {
                    lis_b[i - 1] -= x - lis_b[i];
                    lis_b[i] = 0;
                } lis_b[i] >= x lis_b[i] lis_b i x {
                    lis_b[i] -= x;
                } lis_b[i] -= x lis_b[i] lis_b i x {
                    lis_b[i - 1] -= x - lis_b[i];
                    lis_b[i] = 0;
                } lis_b[i - 1] -= x - lis_b[i] lis_b[i - 1] lis_b i - 1 i 1 x - lis_b[i] x lis_b[i] lis_b i lis_b[i] = 0 lis_b[i] lis_b i 0 System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
    static long mod = 1000000007;

    public static long gcd(long a, long b) {
        if (a == 0) {
            return b;
        } else if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] lis_a = new long[n+1];
        long[] lis_b = new long[n];

        for (int i = 0; i < n + 1; ++i) {
            lis_a[i] = sc.nextLong();
        }
        for (int i = 0; i < n; ++i) {
            lis_b[i] = sc.nextLong();
        }

        long sum = 0;
        for (int i = n; i >= 0; --i) {
            if (i == n) {
                long x = Math.min(lis_a[i], lis_b[i - 1]);
                sum += x;
                lis_b[i - 1] -= x;
            } else if (i == 0) {
                long x = Math.min(lis_a[i], lis_b[i]);
                sum += x;
                lis_b[i] -= x;
            } else {
                long x = Math.min(lis_a[i], lis_b[i] + lis_b[i - 1]);
                sum += x;
                if (lis_b[i] >= x) {
                    lis_b[i] -= x;
                } else {
                    lis_b[i - 1] -= x - lis_b[i];
                    lis_b[i] = 0;
                }
            }
        }

        System.out.println(sum);
    }
} public class Main {
    static long mod = 1000000007;

    public static long gcd(long a, long b) {
        if (a == 0) {
            return b;
        } else if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] lis_a = new long[n+1];
        long[] lis_b = new long[n];

        for (int i = 0; i < n + 1; ++i) {
            lis_a[i] = sc.nextLong();
        }
        for (int i = 0; i < n; ++i) {
            lis_b[i] = sc.nextLong();
        }

        long sum = 0;
        for (int i = n; i >= 0; --i) {
            if (i == n) {
                long x = Math.min(lis_a[i], lis_b[i - 1]);
                sum += x;
                lis_b[i - 1] -= x;
            } else if (i == 0) {
                long x = Math.min(lis_a[i], lis_b[i]);
                sum += x;
                lis_b[i] -= x;
            } else {
                long x = Math.min(lis_a[i], lis_b[i] + lis_b[i - 1]);
                sum += x;
                if (lis_b[i] >= x) {
                    lis_b[i] -= x;
                } else {
                    lis_b[i - 1] -= x - lis_b[i];
                    lis_b[i] = 0;
                }
            }
        }

        System.out.println(sum);
    }
} Main
import java.util.*;

public class Main {
    static long mod = 1000000007;

    public static long gcd(long a, long b) {
        if (a == 0) {
            return b;
        } else if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] lis_a = new long[n+1];
        long[] lis_b = new long[n];

        for (int i = 0; i < n + 1; ++i) {
            lis_a[i] = sc.nextLong();
        }
        for (int i = 0; i < n; ++i) {
            lis_b[i] = sc.nextLong();
        }

        long sum = 0;
        for (int i = n; i >= 0; --i) {
            if (i == n) {
                long x = Math.min(lis_a[i], lis_b[i - 1]);
                sum += x;
                lis_b[i - 1] -= x;
            } else if (i == 0) {
                long x = Math.min(lis_a[i], lis_b[i]);
                sum += x;
                lis_b[i] -= x;
            } else {
                long x = Math.min(lis_a[i], lis_b[i] + lis_b[i - 1]);
                sum += x;
                if (lis_b[i] >= x) {
                    lis_b[i] -= x;
                } else {
                    lis_b[i - 1] -= x - lis_b[i];
                    lis_b[i] = 0;
                }
            }
        }

        System.out.println(sum);
    }
}
