#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

template <typename T>
struct StarrySkyTree //calculateはmin(区間加算区間最小)
{
    int n;
    const T ex = 1ll << 60; //dat 初期値(minなので)
    const T em = 0; //lazy 初期値(加算するので)
    vector<T> dat, lazy; //tree本体
    StarrySkyTree(vector<T> v){
        int x = 1;
        int i;
        n = v.size();
        while(x < n) x <<= 1;
        n = x; 
        dat.resize(2*n-1, ex);
        lazy.resize(2*n-1, em);
        for(i = 0;i < v.size();++i){
            dat.at(i + n - 1) = v.at(i);
        }
        for(i = n-2;i >= 0;--i){
            dat.at(i) = calculate(dat.at(2*i+1), dat.at(2*i+2));
        }
    }
    
    T calculate(T a, T b){
        return min(a, b);
    }
    
    void eval(int now){
        if(lazy.at(now) == em) return;
        if(now < n - 1){ //区間最小なので同じ値を足す。
            lazy.at(2*now + 1) += lazy.at(now);
            lazy.at(2*now + 2) += lazy.at(now);
        }
        dat.at(now) += lazy.at(now); //区間最小なので同じ値を足す。
        lazy.at(now) = em;
    }
    
    void update(int a, int b, T x, int now, int l, int r){
        eval(now);
        if(a <= l && r<= b){
            lazy.at(now) += x; //上から書き換える。区間最小なので同じ値を足す。
            eval(now);
        }else if(a < r && l < b){
            update(a, b, x, 2*now + 1, l, (l + r)/2);
            update(a, b, x, 2*now + 2, (l + r)/2, r);
            dat.at(now) = calculate(dat.at(2*now + 1), dat.at(2*now + 2));
        }
    }
    void update(int a, int b, T x){update(a, b, x, 0, 0, n);}
    
    T query(int a, int b){return query_sub(a, b, 0, 0, n);}
    T query_sub(int a, int b, int now, int l, int r){
        eval(now);
        if(r <= a || b <= l) return ex;
        else if(a <= l && r <= b) return dat.at(now);
        else{
            T vl = query_sub(a, b, 2*now + 1, l, (l + r)/2);
            T vr = query_sub(a, b, 2*now + 2, (l + r)/2, r);
            return calculate(vl, vr);
        }
    }
    
    inline T operator[](int a) { return query(a, a + 1); }
    void print() {
        for (int i = 0; i < 2 * n - 1; ++i) {
            cout << (*this)[i];
            if (i != n) cout << ",";
        }
        cout << endl;
    }
};

int main()
{
    ll i,j;
    ll n,q;
    cin >> n >> q;
    vector<ll> a(n, 0);
    StarrySkyTree<ll> seg(a);
    for(i = 0;i < q;++i){
        ll com;
        cin >> com;
        if(com == 0){
            ll s,t,x;
            cin >> s >> t >> x;
            seg.update(s, t+1, x);
        }else{
            ll s,t;
            cin >> s >> t;
            cout << seg.query(s, t+1) << endl;
        }
    }

    return 0;
}
