#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <shared_mutex>

#ifdef DEBUG
#include "libs/debug.cpp"
#define DEBUG 1
#else
#define DEBUG 0
#endif

#define rep(i, n) repr((i), 0, (n))
#define repr(i, a, t) reps((i), (a), (t), 1)
#define reps(i, a, t, s) for (long long (i) = (a); (i) < (long long)(t); (i) += (s))
#define rrep(i, n) rrepr((i), (n), 0)
#define rrepr(i, a, t) rreps((i), (a), (t), 1)
#define rreps(i, a, t, s) for (long long (i) = (a) - 1; (i) >= (long long)(t); (i) -= (s))
#define each(v, c) for (auto &&(v) : (c))
#define all(c) (c).begin(), (c).end()

using namespace std;

// コンテナのメンバ関数を使わないと O(N) おぼえたらけす
template<typename T>
typename set<T>::iterator lower_bound(typename set<T>::iterator l, typename set<T>::iterator r, const T &v);
template<typename T>
typename set<T>::iterator upper_bound(typename set<T>::iterator l, typename set<T>::iterator r, const T &v);
template<typename S, typename T>
typename map<S, T>::iterator lower_bound(typename map<S, T>::iterator l, typename map<S, T>::iterator r, const T &v);
template<typename S, typename T>
typename map<S, T>::iterator upper_bound(typename map<S, T>::iterator l, typename map<S, T>::iterator r, const T &v);

using ll = long long;
using ull = unsigned long long;
using ld = long double;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;

template<typename E, typename T>
class LazySegmentTree {
 private:
  E _e_id;
  T _t_id;
  size_t _size;
  function<E(E, E)> _fn1;
  function<E(E, T)> _fn2;
  function<T(T, T)> _fn3;
  function<T(T, ll)> _fn4;

  /**
   * _tree[k] の親たちを最新化する
   * @param k
   */
  void _update_parents(int k) {
    k >>= 1;
    while (k > 0) {
      _tree[k] = _fn2(
          _fn1(_tree[k << 1], _tree[k << 1 | 1]),
          _fn4(_lazy[k], _leaves_counts[k]));
      k >>= 1;
    }
  }

  /**
   * k の部分木の葉に一様に value を適用する
   * @param k
   */
  void _apply_to_subtree(int k, T value) {
    _tree[k] = _fn2(_tree[k], _fn4(value, _leaves_counts[k]));
    if (k < _size) {
      _lazy[k] = _fn3(_lazy[k], value);
    }
  }

  /**
   * k とその親たちの遅延配列を評価する
   * @param k
   */
  void _eval_parents(int k) {
    int h = 0;
    while ((k >> h) > 1) h++;
    for (; h > 0; h--) {
      int p = k >> h;
      _apply_to_subtree(p << 1, _lazy[p]);
      _apply_to_subtree(p << 1 | 1, _lazy[p]);
      _lazy[p] = _t_id;
    }
  }

 public:
  vector<E> _tree;
  vector<T> _lazy;
  vector<ll> _leaves_counts;

  LazySegmentTree(
      const vector<E> &values,
      E e_id,
      T t_id,
      function<E(E, E)> fn1,
      function<E(E, T)> fn2,
      function<E(E, E)> fn3,
      function<E(E, ll)> fn4 = [](E e, ll n) { return e; }
  ) : _e_id(e_id),
      _t_id(t_id),
      _fn1(std::move(fn1)),
      _fn2(std::move(fn2)),
      _fn3(std::move(fn3)),
      _fn4(std::move(fn4)) {
    _size = values.size();
    _tree.resize(_size * 2, _e_id);
    _lazy.resize(_size * 2, _t_id);
    _leaves_counts.resize(_size * 2, 1);

    for (int i = 0; i < _size; i++) {
      _tree[i + _size] = values[i];
    }
    for (int i = _size - 1; i > 0; i--) {
      _tree[i] = _fn1(_tree[i << 1], _tree[i << 1 | 1]);
      _leaves_counts[i] = _leaves_counts[i << 1] + _leaves_counts[i << 1 | 1];
    }
  }

  /**
   * [l, r) の範囲に value を適用する
   * @param l
   * @param r
   * @param value
   */
  void apply(int l, int r, T value) {
    l += _size;
    r += _size;
    int l0 = l;
    int r0 = r;
    while (l < r) {
      if (l & 1) {
        _apply_to_subtree(l++, value);
      }
      if (r & 1) {
        _apply_to_subtree(--r, value);
      }
      l >>= 1;
      r >>= 1;
    }
    _update_parents(l0);
    _update_parents(r0 - 1);
  }

  /**
   * [l, r) に fn1 を適用した値を返す
   * @param l
   * @param r
   */
  auto query(int l, int r) -> E {
    l += _size;
    r += _size;
    _eval_parents(l);
    _eval_parents(r - 1);

    vector<E> ret, ret_r;
    while (l < r) {
      if (l & 1) {
        ret.push_back(_tree[l++]);
      }
      if (r & 1) {
        ret_r.push_back(_tree[--r]);
      }
      l >>= 1;
      r >>= 1;
    }
    reverse(ret_r.begin(), ret_r.end());
    ret.insert(ret.end(), ret_r.begin(), ret_r.end());
    return accumulate(ret.begin(), ret.end(), _e_id, _fn1);
  }
};

auto main() -> int {
  cout << fixed << setprecision(10);
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ifstream ifs;
  if (DEBUG) {
    ifs.open("src/_in.txt");
    cin.rdbuf(ifs.rdbuf());
  }

  ll N, Q;
  cin >> N >> Q;

  vector<ll> values(N, 0);
  ll e_id = INF;
  ll t_id = 0;
  auto fn1 = [](ll a, ll b) { return min(a, b); };
  auto fn2 = [](ll a, ll b) { return a + b; };
  auto fn3 = [](ll a, ll b) { return a + b; };
  auto st = LazySegmentTree<ll, ll>(values, e_id, t_id, fn1, fn2, fn3);
  rep (i, Q) {
    ll op;
    cin >> op;
    if (op == 0) {
      int s, t, x;
      cin >> s >> t >> x;
      st.apply(s, t + 1, x);
    } else {
      int s, t;
      cin >> s >> t;
      ll a = st.query(s, t + 1);
      cout << a << "\n";
    }
  }
}


Measured memory_bytes: 8380