#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;

// #define DEBUG

class RangeAddorUpdateQuery // 0-index
{
    int const intmax = 2147483647;
    int const intmin = 0;
    int const intmin2 = -2147483647;
    vector<ll> segtree;
    vector<ll> lazytree; //　遅延ツリーの方はintで収まらないことがある
    int n;
    int k;

public:
    RangeAddorUpdateQuery(int n1, int f = -1)
    {
        if (f == -1)
            f = intmax;
        else if (f == 0)
            f = intmin;
        int na = 1;
        int ka = 0;
        while (na < n1)
        {
            na *= 2;
            ka++;
        }
        for (int i = 0; i < 2 * na; i++)
        {
            segtree.push_back(f);
            lazytree.push_back(f);
        }
        n = na;
        k = ka;
    }

    void lazyupgladeevaluation(int k, int l, int r)
    {
        int k2;
        if (lazytree[k] != intmax)
        {
            segtree[k] = lazytree[k];
            k2 = k / 2;
            while (k2 > 0)
            {
                segtree[k2] = min(segtree[2 * k2], segtree[2 * k2 + 1]); //最小値を上の段に伝播させる
                k2 = k2 / 2;
            }

            if (r - l > 1) //最下段以外は一段下に伝播
            {
                lazytree[2 * k + 1] = lazytree[k];
                lazytree[2 * k] = lazytree[k];
            }
            lazytree[k] = intmax;
        }
    }

    void lazyaddevaluation(int k, int l, int r)
    {
        int k2;
        if (lazytree[k] != 0)
        {
            segtree[k] += lazytree[k];
            k2 = k / 2;
            while (k2 > 0)
            {
                segtree[k2] = min(segtree[2 * k2], segtree[2 * k2 + 1]); //最小値を上の段に伝播させる
                k2 = k2 / 2;
            }
            if (r - l > 1) //最下段以外は一段下に伝播
            {
                lazytree[2 * k + 1] += lazytree[k];
                lazytree[2 * k] += lazytree[k];
            }
            lazytree[k] = 0;
        }
    }

    void rangeupdate(int a, int b, ll x, int k = 1, int l = 0, int r = -1) //閉区間 l <= x < r とする
    {
        if (r == -1)
            r = n;
        lazyupgladeevaluation(k, l, r);
        if (r <= a || b <= l)
            return;
        if (a == l && b == r)
        {
            lazytree[k] = x;
            lazyupgladeevaluation(k, l, r);
        }
        else
        {
            rangeupdate(a, min(b, (l + r) / 2), x, 2 * k, l, (l + r) / 2);
            rangeupdate(max(a, (l + r) / 2), b, x, 2 * k + 1, (l + r) / 2, r);
        }
    }

    void rangeadd(int a, int b, ll x, int k = 1, int l = 0, int r = -1) //閉区間 l <= x < r とする
    {
        int k2;
        if (r == -1)
            r = n;
        lazyaddevaluation(k, l, r);
        if (r <= a || b <= l)
            return;
        if (a == l && b == r)
        {
            lazytree[k] = x;
            lazyaddevaluation(k, l, r);
        }
        else
        {
            rangeadd(a, min(b, (l + r) / 2), x, 2 * k, l, (l + r) / 2);
            rangeadd(max(a, (l + r) / 2), b, x, 2 * k + 1, (l + r) / 2, r);
        }
    }

    ll getmin(int a, int b, int k = 1, int l = 0, int r = -1) //閉区間 l <= x < r とする
    {
        if (r == -1)
            r = n;
        lazyupgladeevaluation(k, l, r);
        if (r <= a || b <= l)
            return intmax;
        if (a == l && b == r)
            return segtree[k];
        else
            return min(getmin(a, min(b, (l + r) / 2), 2 * k, l, (l + r) / 2), getmin(max(a, (l + r) / 2), b, 2 * k + 1, (l + r) / 2, r));
    }
    int getmax(int a, int b, int k = 1, int l = 0, int r = -1) //閉区間 l <= x < r とする
    {
        if (r == -1)
            r = n;
        lazyaddevaluation(k, l, r);
        if (r <= a || b <= l)
            return intmin;
        if (a == l && b == r)
            return segtree[k];
        else
            return min(getmax(a, min(b, (l + r) / 2), 2 * k, l, (l + r) / 2), getmax(max(a, (l + r) / 2), b, 2 * k + 1, (l + r) / 2, r));
    }
    ll getsum(int a, int b, int k = 1, int l = 0, int r = -1) //閉区間 l <= x < r とする
    {
        if (r == -1)
            r = n;
        lazyaddevaluation(k, l, r);
        if (r <= a || b <= l)
            return intmin;
        if (a == l && b == r)
        {
            return segtree[k];
        }
        else
            return getsum(a, min(b, (l + r) / 2), 2 * k, l, (l + r) / 2) + getsum(max(a, (l + r) / 2), b, 2 * k + 1, (l + r) / 2, r);
    }

    void printsegtree()
    {
        for (int i = 0; i < 2 * n; i++)
        {
            cout << segtree[i] << " ";
        }
        cout << endl;
        for (int i = 0; i < 2 * n; i++)
        {
            cout << lazytree[i] << " ";
        }
        cout << endl;
    }
};

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, q, k, c, s, t;
    ll x, y;
    cin >> n >> q;
    RangeAddorUpdateQuery segtree(n);

    for (int i = 0; i < q; i++)
    {
        cin >> c;
        if (c == 0)
        {
            cin >> s >> t >> x;
            segtree.rangeupdate(s, t + 1, x);
        }
        else
        {
            cin >> x >> y;
            cout << segtree.getmin(x, y + 1) << endl;
        }
    }
    return 0;
}

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)


Measured memory_bytes: 7136