#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < n; i++)
template<typename DATA_TYPE, typename LAZY_TYPE, typename F, typename G, typename H, typename P>
class SegmentTree {
  private:
	size_t size;

	F f;
	G g;
	H h;
	P p;

	std::vector<DATA_TYPE> data;
	std::vector<LAZY_TYPE> lazy;
	DATA_TYPE data_init;
	LAZY_TYPE lazy_init;

	vector<bool> use_lazy_flag;

	SegmentTree() : size(0) {}

	void eval(int length, size_t index) {
		if (!use_lazy_flag[index]) return;
		if (index * 2 + 1 < size * 2 - 1) {
			use_lazy_flag[index * 2 + 1] = use_lazy_flag[index * 2 + 2] = true;
			lazy[index * 2 + 1] = h(lazy[index * 2 + 1], lazy[index]);
			lazy[index * 2 + 2] = h(lazy[index * 2 + 2], lazy[index]);
		}
		data[index] = g(data[index], p(lazy[index], length));
		lazy[index] = lazy_init;
		use_lazy_flag[index] = false;
	}

	void update(size_t begin, size_t end, LAZY_TYPE update_value, size_t index, size_t left, size_t right) {
		eval(right - left, index);
		if (right <= begin || end <= left) return;
		if (begin <= left && right <= end) {
			lazy[index] = h(lazy[index], update_value);
			use_lazy_flag[index] = true;
			eval(right - left, index);
		}
		else {
			update(begin, end, update_value, index * 2 + 1, left, (left + right) / 2);
			update(begin, end, update_value, index * 2 + 2, (left + right) / 2, right);
			data[index] = f(data[2 * index + 1], data[2 * index + 2]);
		}
	}

	DATA_TYPE query(size_t begin, size_t end, size_t index, size_t left, size_t right) {
		eval(right - left, index);
		if (right <= begin || end <= left) return data_init;
		if (begin <= left && right <= end) return data[index];
		return f(query(begin, end, index * 2 + 1, left, (left + right) / 2), query(begin, end, index * 2 + 2, (left + right) / 2, right));
	}

  public:
	SegmentTree(size_t data_size, F f, G g, H h, P p, DATA_TYPE data_init, LAZY_TYPE lazy_init) : f(f), g(g), h(h), p(p), data_init(data_init), lazy_init(lazy_init) {
		size = 1;
		while (size < data_size) size <<= 1U;
		data.resize(2 * size - 1, data_init);
		lazy.resize(2 * size - 1, lazy_init);
		use_lazy_flag.resize(2 * size - 1, false);
	}

	void update(size_t begin, size_t end, LAZY_TYPE update_value) {
		update(begin, end, update_value, 0, 0, size);
	}

	DATA_TYPE query(size_t begin, size_t end) {
		return query(begin, end, 0, 0, size);
	}

    void build(std::vector<DATA_TYPE> input_data) {
        if (input_data.size() > size) {
            std::cerr << "segment tree::build : input oversize data\n";
            exit(-1);
        }
        for (int i = 0; i < input_data.size(); ++i) {
            data[i + size - 1] = input_data[i];
        }
        for (int i = size - 2; i >= 0; --i) {
            data[i] = f(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }
};
signed main(signed argc, char* argv[]) {
	cin.tie(nullptr);
	cout.tie(nullptr);
	ios::sync_with_stdio(false);
    auto f = [](int a, int b) { return min(a, b); };
    auto g = [](int a, int b) { return a + b; };
    auto h = [](int a, int b) { return a + b; };
    auto p = [](int a, size_t b) { return a; };
	int n, q;
	cin >> n >> q;
	SegmentTree<int, int, decltype(f), decltype(g), decltype(h), decltype(p)> segTree(n, f, g, h, p, 10000000000007LL, 0);
	segTree.build(vector<int>(n,0));
	rep(i, q) {
		int qt;
		cin >> qt;
		if (qt) {
			int s, t;
			cin >> s >> t;
			cout << segTree.query(s, t + 1) << endl;
		}
		else {
			int s, t, x;
			cin >> s >> t >> x;
			segTree.update(s, t + 1, x);
		}
	}
}



Measured memory_bytes: 7876