#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

struct SegTree {
    int n;
    vll data;
    vll lazy;

    SegTree(int m) {
        n = 1;
        while(n < m) n *= 2;
        data = vll(2 * this->n - 1, 0); // need to change
        lazy = vll(2 * this->n - 1, 0);  // need to change
    }

    void eval(int k) {
        if(lazy[k] == 0) return;    // need to change
        if(k < n - 1) {
            lazy[k * 2 + 1] += lazy[k];  // need to change
            lazy[k * 2 + 2] += lazy[k];  // need to change
        }
        data[k] += lazy[k];  // need to change
        lazy[k] = 0; // need to change
    }

    void update(int a, int b, ll x, int k, int l, int r) {
        eval(k);
        if(a <= l && r <= b) {
            lazy[k] += x;    // need to change
            eval(k);
        }
        else if(a < r && l < b) {
            update(a, b, x, k * 2 + 1, l, (l + r) / 2);
            update(a, b, x, k * 2 + 2, (l + r) / 2, r);
            data[k] = min(data[k * 2 + 1], data[k * 2 + 2]);
        }
    }

    void update(int a, int b, ll x) {   // update for [a, b)
        update(a, b, x, 0, 0, n);
    }

    ll query(int a, int b, int k, int l, int r) {
        eval(k);
        if(r <= a || b <= l) {
            return INFL;    // need to change
        }
        if(a <= l && r <= b) {
            return data[k];
        }
        else {
            ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return min(vl, vr); // need to change
        }
    }

    ll query(int a, int b) {
        return query(a, b, 0, 0, n);   // query for [a, b)
    }
};

void solve() {
    ll n, q;
    cin >> n >> q;
    SegTree st(n);
    vll ans;
    for(ll i = 0; i < q; i++) {
        ll c;
        cin >> c;
        if(c == 0) {
            ll s, t, x;
            cin >> s >> t >> x;
            st.update(s, t + 1, x);
        }
        else {
            ll s, t;
            cin >> s >> t;
            ans.push_back(st.query(s, t + 1));
        }
    }
    for(auto i : ans) cout << i << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 7984