#include <cstdio>
#include <functional>
#include <vector>

using namespace std;

#define int long long
#define dotimes(i, n) for (int i = 0, i##max__ = (n); i < i##max__; i++)
#define whole(x, f, ...) ([&](decltype((x)) c) { return (f)(begin(c), end(c), ## __VA_ARGS__); })(x)

int rint() {
  int x;
  scanf("%lld", &x);
  return x;
}

void wint(int x) {
  printf("%lld\n", x);
}

template<typename T> int size(T const& c) { return static_cast<int>(c.size()); }
template <typename T> bool maxs(T& a, T const& b) { return a < b ? a = b, true : false; }
template <typename T> bool mins(T& a, T const& b) { return a > b ? a = b, true : false; }
inline int lg(int x) { return 63 - __builtin_clzll(static_cast<unsigned int>(x)); }

class segment_tree {
  vector<pair<int, int>> xs;
public:
  segment_tree(int n) : xs(1 << (lg(2 * n - 1) + 1)) {}
  void update(const int i, const int j, int x) {
    function<void(int, int, int)> rec;
    rec =
      [&](int k, int a, int b) {
        if (i <= a && b <= j) {
          xs[k].first += x;
          xs[k].second += x;
        } else {
          int c = a + (b - a) / 2;
          if (xs[k].second != 0) {
            xs[2*k].first += xs[k].second;
            xs[2*k].second += xs[k].second;
            xs[2*k+1].first += xs[k].second;
            xs[2*k+1].second += xs[k].second;
            xs[k].second = 0;
          }
          if (j <= c)
            rec(2*k, a, c);
          else if (c <= i)
            rec(2*k+1, c, b);
          else {
            rec(2*k, a, c);
            rec(2*k+1, c, b);
          }
          xs[k].first = min(xs[2*k].first, xs[2*k+1].first);
        }
      };
    rec(1, 0, ::size(xs)/2);
  }
  int query(const int i, const int j) {
    function<int(int, int, int)> rec;
    rec =
      [&](int k, int a, int b) {
        if (i <= a && b <= j)
          return xs[k].first;
        int c = a + (b - a) / 2;
        return xs[k].second + (j <= c ? rec(2*k, a, c) : c <= i ? rec(2*k+1, c, b) : min(rec(2*k, a, c), rec(2*k+1, c, b)));
      };
    return rec(1, 0, ::size(xs)/2);
  }
};

signed main() {
  const int n = rint();
  segment_tree st(n);
  const int q = rint();
  dotimes(i, q)
    if (rint()) {
      int s = rint();
      int t = rint();
      wint(st.query(s, t+1));
    } else {
      int s = rint();
      int t = rint();
      int x = rint();
      st.update(s, t+1, x);
    }
  return 0;
}

