using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        SetOut(new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        var N = FastIO.Int();
        var Q = FastIO.Int();
        var d = new SegmentTree<int, int>(new int[N], Min, (x, y) => x + y, (x, y) => x + y, int.MaxValue, 0);
        for (int i = 0; i < Q; i++)
        {
            if (FastIO.Int() == 0)
            {
                var s = FastIO.Int();
                var t = FastIO.Int() + 1;
                var x = FastIO.Int();
                d.Update(s, t, x);
            }
            else
            {
                var s = FastIO.Int();
                var t = FastIO.Int() + 1;
                WriteLine(d.Query(s, t));
            }
        }
        Out.Flush();
    }
}

public static class FastIO
{
    static System.IO.Stream str = System.Console.OpenStandardInput();
    const int size = 1024;
    static byte[] buffer = new byte[size];
    static int ptr;
    static int len;

    static byte Read()
    {
        if (ptr == len)
        {
            len = str.Read(buffer, 0, size);
            if (len == 0) return 0;
            ptr = 0;
        }
        return buffer[ptr++];
    }

    public static int Int()
    {
        var c = Read();
        while (c < 0x21)
        {
            c = Read();
        }
        var n = false;
        if (c == '-')
        {
            n = true;
            c = Read();
        }
        var ret = 0;
        while (c > 0x20)
        {
            ret = ret * 10 + c - '0';
            c = Read();
        }
        return n ? -ret : ret;
    }

    public static long Long()
    {
        var c = Read();
        while (c < 0x21)
        {
            c = Read();
        }
        var n = false;
        if (c == '-')
        {
            n = true;
            c = Read();
        }
        var ret = 0L;
        while (c > 0x20)
        {
            ret = ret * 10 + c - '0';
            c = Read();
        }
        return n ? -ret : ret;
    }
}

public class SegmentTree<T, E>// where E : IEquatable<E>
{
    T[] buffer;
    E[] lazy;
    Func<T, T, T> F;
    Func<T, E, T> G;
    Func<E, E, E> H;
    T TI;
    E EI;
    int N;
    public int Length => N;
    int height;

    public SegmentTree(int length, Func<T, T, T> f, Func<T, E, T> g, Func<E, E, E> h, T ti, E ei)
    {
        F = f;
        G = g;
        H = h;
        TI = ti;
        EI = ei;

        N = length;
        height = 1;//!log2
        while (1 << height < length) height++;

        buffer = new T[N * 2];
        for (int i = 0; i < buffer.Length; i++) buffer[i] = TI;//Array.Fill

        lazy = new E[N * 2];
        for (int i = 0; i < lazy.Length; i++) lazy[i] = EI;//Array.Fill
    }

    public SegmentTree(T[] init, Func<T, T, T> f, Func<T, E, T> g, Func<E, E, E> h, T ti, E ei)
    {
        F = f;
        G = g;
        H = h;
        TI = ti;
        EI = ei;

        N = init.Length;
        height = 1;//!log2
        while (1 << height < N) height++;

        buffer = new T[N * 2];
        Array.Copy(init, 0, buffer, N, init.Length);
        for (int i = N + init.Length; i < buffer.Length; i++) buffer[i] = TI;
        for (int i = N - 1; i != 0; i--) buffer[i] = F(buffer[i * 2 + 0], buffer[i * 2 + 1]);

        lazy = new E[N * 2];
        for (int i = 0; i < lazy.Length; i++) lazy[i] = EI;//Array.Fill
    }

    T Reflect(int k)
    {
        //if (lazy[k].Equals(EI)) return buffer[k];//Type Classes!//lazy[k] == EI
        return G(buffer[k], lazy[k]);
    }

    void Propagate(int k)
    {
        //if (lazy[k].Equals(EI)) return;//Type Classes!//lazy[k] == EI
        lazy[k * 2 + 0] = H(lazy[k * 2 + 0], lazy[k]);
        lazy[k * 2 + 1] = H(lazy[k * 2 + 1], lazy[k]);
        buffer[k] = Reflect(k);
        lazy[k] = EI;
    }

    void Thrust(int k)
    {
        for (int i = height; i != 0; i--) Propagate(k >> i);
    }

    void Recalc(int k)
    {
        while ((k >>= 1) != 0) buffer[k] = F(Reflect(k * 2 + 0), Reflect(k * 2 + 1));
    }

    public void Update(int l, int r, E v)
    {
        var a = l += N;
        var b = (r += N) - 1;
        for (; l < r; l >>= 1, r >>= 1)
        {
            if ((l & 1) != 0) { lazy[l] = H(lazy[l], v); l++; }
            if ((r & 1) != 0) { --r; lazy[r] = H(lazy[r], v); }
        }
        Recalc(a);
        Recalc(b);
    }

    public T Query(int l, int r)
    {
        Thrust(l += N);
        Thrust(r += N - 1);
        var vl = TI;
        var vr = TI;
        for (r++; l < r; l >>= 1, r >>= 1)
        {
            if ((l & 1) != 0) vl = F(vl, Reflect(l++));
            if ((r & 1) != 0) vr = F(Reflect(--r), vr);
        }
        return F(vl, vr);
    }

    public void Set(int i, T v)
    {
        var k = i + N;
        Thrust(k);
        buffer[k] = v;
        lazy[k] = EI;
        Recalc(k);
    }

    public T Get(int i)
    {
        var k = i + N;
        Thrust(k);
        return Reflect(k);
    }
}


Measured memory_bytes: 19212