#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

class LazySegmentTree {
    vector<int64_t> container;
    vector<int64_t> lazyContainer;

public:
    LazySegmentTree(int size)
        : container(msb1(size * 2 - 1))
        , lazyContainer(msb1(size * 2 - 1))
    {
    }

    void add(size_t s, size_t t, int64_t x)
    {
        add_inner(s, t, 0, container.size() / 2, 1, x);
    }

    int64_t find(size_t s, size_t t)
    {
        if (s >= t) {
            return 0;
        }
        return find_inner(s, t, 0, container.size() / 2, 1);
    }

    void debug()
    {
        for (int64_t i : container) {
            cout << i << "\t";
        }
        cout << endl;
        for (int64_t i : lazyContainer) {
            cout << i << "\t";
        }
        cout << endl;
    }

private:
    void add_inner(size_t s, size_t t, size_t lb, size_t ub, size_t node, int64_t x)
    {
        if (s == lb && t == ub) {
            lazyContainer[node] += x;
            maintain(node);
            return;
        }

        size_t mid = (lb + ub) / 2;
        if (mid > s) {
            add_inner(s, min(mid, t), lb, mid, node * 2, x);
        }
        if (mid < t) {
            add_inner(max(mid, s), t, mid, ub, node * 2 + 1, x);
        }
        maintain(node * 2);
        maintain(node * 2 + 1);
        container[node] = min(container[node * 2], container[node * 2 + 1]);
    }

    int64_t find_inner(size_t s, size_t t, size_t lb, size_t ub, size_t node)
    {
        maintain(node);
        if (s == lb && t == ub) {
            return container[node];
        }

        int64_t result = numeric_limits<int64_t>::max();
        size_t mid = (lb + ub) / 2;
        if (mid > s) {
            result = min(result, find_inner(s, min(mid, t), lb, mid, node * 2));
        }
        if (mid < t) {
            result = min(result, find_inner(max(s, mid), t, mid, ub, node * 2 + 1));
        }

        return result;
    }
    void maintain(size_t node)
    {
        container[node] += lazyContainer[node];
        size_t child = node * 2;
        if (child < container.size()) {
            lazyContainer[child] += lazyContainer[node];
            lazyContainer[child + 1] += lazyContainer[node];
        }
        lazyContainer[node] = 0;
    }
    int msb1(int x)
    {
        x |= x >> 1;
        x |= x >> 2;
        x |= x >> 4;
        x |= x >> 8;
        x |= x >> 16;

        return x + 1;
    }
};

int main()
{
    int n, q;
    cin >> n >> q;

    LazySegmentTree seg(n);

    rep(i, q)
    {
        int com;
        int s, t;
        cin >> com >> s >> t;
        if (com == 0) {
            int x;
            cin >> x;

            seg.add(s, t + 1, x);
        } else {
            cout << seg.find(s, t + 1) << endl;
        }
        //seg.debug();
    }
    return 0;
}


Measured memory_bytes: 7064