#include <bits/stdc++.h>
#include <cmath>

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

// https://onlinejudge.u-aizu.ac.jp/solutions/problem/DSL_2_F/review/3380631/face4/C++14

struct STlazy {
private:
    int n;
    vector<ll> node, lazy;

public:
    STlazy() {
        n = (1 << 17) - 1;
        node.resize(2 * n - 1, 0);
        lazy.resize(2 * n - 1, -INF);
    }

    void eval(int k, int l, int r) {
        if (lazy[k] == -INF) return;
        node[k] += lazy[k];
        if (r - l > 1) {
            if (lazy[2 * k + 1] != -INF) lazy[2 * k + 1] += lazy[k];
            else lazy[2 * k + 1] = lazy[k];
            if (lazy[2 * k + 2] != -INF) lazy[2 * k + 2] += lazy[k];
            else lazy[2 * k + 2] = lazy[k];
        }
        lazy[k] = -INF;
    }

    void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        eval(k, l, r);
        if (r <= a || b <= l) return;
        if (a <= l && r <= b) {
            if (lazy[k] != -INF) lazy[k] += x;
            else lazy[k] = x;
            eval(k, l, r);
            return;
        }
        add(a, b, x, 2 * k + 1, l, (l + r) / 2);
        add(a, b, x, 2 * k + 2, (l + r) / 2, r);
        node[k] = min(node[2 * k + 1], node[2 * k + 2]);
    }

    ll query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return INF;
        eval(k, l, r);
        if (a <= l && r <= b) return node[k];
        ll lx = query(a, b, 2 * k + 1, l, (l + r) / 2);
        ll rx = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return min(lx, rx);
    }
};

int main() {

    int n, q;
    cin >> n >> q;

    STlazy st;

    rep(i, q) {
        int query;
        cin >> query;

        if (query == 0) {
            int s, t, x;
            cin >> s >> t >> x;
            t++;
            st.add(s, t, x);
        } else if (query == 1) {
            int s, t;
            cin >> s >> t;
            t++;
            cout << st.query(s, t) << endl;
        }

    }

}



Measured memory_bytes: 7092