#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


struct Monoid {
  using T = int;
  static T op(const T& lhs, const T& rhs) { return min(lhs, rhs); }
  static constexpr T e() { return numeric_limits<int>::max(); }
};

template<class Monoid> struct MonoidAct {
  using T = int;
  static void ap(const T& act, typename Monoid::T& val, int len) { val += act; }
  static void cp(const T& lhs, T& rhs) { rhs += lhs; }
  static constexpr T id() { return 0; }
};

template<class Monoid, class MonoidAct> struct SegmentTree {
  using Tv = typename Monoid::T;
  using Ta = typename MonoidAct::T;
  struct Node {
    lint l, r, m, len;
    Tv val;
    Ta act;
    unique_ptr<Node> cl, cr;
    Node(lint l, lint r) : l(l), r(r), m(l + r >> 1), len(r - l), val(Monoid::e()), act(MonoidAct::id()) {}
  };

  lint n;
  unique_ptr<Node> root;

  SegmentTree(lint n) : n(n), root(make_unique<Node>(0, n)) {}

  Tv get(lint l, lint r) { return _get(l, r, root); }

  void set(lint l, lint r, const Ta& f) { _set(l, r, f, root); }
  void set(lint i, const Tv& a) { _set(i, a, root); }

  Tv _get(lint l, lint r, const unique_ptr<Node>& v) {
    if (l <= v->l and v->r <= r) return v->val;
    if (v->act != MonoidAct::id()) _push(v);
    Tv resl = Monoid::e(), resr = Monoid::e();
    if (l < v->m) {
      if (v->cl == nullptr) v->cl = make_unique<Node>(v->l, v->m);
      resl = _get(l, r, v->cl);
    }
    if (v->m < r) {
      if (v->cr == nullptr) v->cr = make_unique<Node>(v->m, v->r);
      resr = _get(l, r, v->cr);
    }
    return Monoid::op(resl, resr);
  }

  void _push(const unique_ptr<Node>& v) {
    if (v->cl == nullptr) v->cl = make_unique<Node>(v->l, v->m);
    MonoidAct::ap(v->act, v->cl->val, v->cl->len);
    MonoidAct::cp(v->act, v->cl->act);
    if (v->cr == nullptr) v->cr = make_unique<Node>(v->m, v->r);
    MonoidAct::ap(v->act, v->cr->val, v->cr->len);
    MonoidAct::cp(v->act, v->cr->act);
    v->act = MonoidAct::id();
  }

  void _set(lint l, lint r, const Ta& f, const unique_ptr<Node>& v) {
    if (l <= v->l and v->r <= r) {
      MonoidAct::ap(f, v->val, v->len);
      MonoidAct::cp(f, v->act);
      return;
    }
    if (v->act != MonoidAct::id()) _push(v);
    if (l < v->m) {
      if (v->cl == nullptr) v->cl = make_unique<Node>(v->l, v->m);
      _set(l, r, f, v->cl);
    }
    if (v->m < r) {
      if (v->cr == nullptr) v->cr = make_unique<Node>(v->m, v->r);
      _set(l, r, f, v->cr);
    }
    v->val = Monoid::op(v->cl != nullptr ? v->cl->val : Monoid::e(), v->cr != nullptr ? v->cr->val : Monoid::e());
  }

  void _set(lint i, const Tv& a, const unique_ptr<Node>& v) {
    if (v->len == 1) {
      v->val = a;
      return;
    }
    if (v->act != MonoidAct::id()) _push(v);
    if (i < v->m) {
      if (v->cl == nullptr) v->cl = make_unique<Node>(v->l, v->m);
      _set(i, a, v->cl);
    } else {
      if (v->cr == nullptr) v->cr = make_unique<Node>(v->m, v->r);
      _set(i, a, v->cr);
    }
    v->val = Monoid::op(v->cl != nullptr ? v->cl->val : Monoid::e(), v->cr != nullptr ? v->cr->val : Monoid::e());
  }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, q; cin >> n >> q;
  SegmentTree< Monoid, MonoidAct<Monoid> > st(n);
  for (int i = 0; i < n; ++i) st.set(i, 0);
  for (int i = 0; i < q; ++i) {
    int c; cin >> c;
    if (!c) {
      int s, t, x; cin >> s >> t >> x, ++t;
      st.set(s, t, x);
    } else {
      int s, t; cin >> s >> t, ++t;
      cout << st.get(s, t) << '\n';
    }
  }
}


Measured memory_bytes: 15708