#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;

  const int n;
  V<Tv> val;
  V<Ta> act;
  V<> len;

  SegmentTree(int n) : n(n), val(2 * n, Monoid::e()), act(n, MonoidAct::id()), len(2 * n, 1) {
    for (int i = n - 1; i > 0; --i) len[i] = len[2 * i] + len[2 * i + 1];
  }
  template<class Itr> SegmentTree(Itr first, Itr last) : n(distance(first, last)), val(2 * n, Monoid::e()), act(n, MonoidAct::id()), len(2 * n, 1) {
    copy(first, last, next(begin(val), n));
    build();
    for (int i = n - 1; i > 0; --i) len[i] = len[2 * i] + len[2 * i + 1];
  }

  void build() {
    for (int i = n - 1; i > 0; --i) val[i] = Monoid::op(val[2 * i], val[2 * i + 1]);
  }

  Tv get(int l, int r) {
    _push(l, r);
    Tv resl = Monoid::e(), resr = Monoid::e();
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) resl = Monoid::op(resl, val[l++]);
      if (r & 1) resr = Monoid::op(val[--r], resr);
    }
    return Monoid::op(resl, resr);
  }
  Tv get(int i) { return get(i, i + 1); }

  void push() {
    for (int i = 1; i < n; ++i) _push(i);
  }

  void set(int l, int r, const Ta& f) {
    _push(l, r);
    for (int i = l + n, j = r + n; i < j; i >>= 1, j >>= 1) {
      if (i & 1) _ap(f, i++);
      if (j & 1) _ap(f, --j);
    }
    for (l += n; !(l & 1); l >>= 1);
    while ((l >>= 1) > 0) val[l] = Monoid::op(val[2 * l], val[2 * l + 1]);
    for (r += n; !(r & 1); r >>= 1);
    while ((r >>= 1) > 0) val[r] = Monoid::op(val[2 * r], val[2 * r + 1]);
  }
  void set(int i, const Tv& a) {
    _push(i, i + 1);
    for (val[i += n] = a, i >>= 1; i > 0; i >>= 1) val[i] = Monoid::op(val[2 * i], val[2 * i + 1]);
  }

  void _ap(const Ta& f, int i) {
    MonoidAct::ap(f, val[i], len[i]);
    if (i < n) MonoidAct::cp(f, act[i]);
  }

  void _push(int i) {
    _ap(act[i], 2 * i);
    _ap(act[i], 2 * i + 1);
    act[i] = MonoidAct::id();
  }
  void _push(int l, int r) {
    for (int hl = __lg(l + n), hr = __lg(r - 1 + n); hr > 0; --hl, --hr) {
      int al = l + n >> hl, ar = r - 1 + n >> hr;
      if (al < n) _push(al);
      if (ar != al) _push(ar);
    }
  }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, q; cin >> n >> q;
  V<> a(n);
  SegmentTree< Monoid, MonoidAct<Monoid> > st(begin(a), end(a));
  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: 5112