#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

template <typename T>
struct service {
  size_t L;
  std::vector<T> dat;
  std::vector<T> dividend;
  std::vector<int> paid;
  std::vector<T> mim;

  explicit service(size_t n, T x)
    : L(csqrt(n))
    , dat(L * L, x)
    , dividend(L, 0)
    , paid(L, true)
    , mim(L, x)
  { }

  void pay(size_t g) {
    if (paid[g]) { return; }
    T v = dividend[g];
    for (size_t i = g * L; i < (g + 1) * L; ++i) {
      dat[i] += v;
    }
    dividend[g] = 0;
    paid[g] = true;
  }

  void compute_mim(size_t g) {
    assert(paid[g]);
    T ans = dat[g * L];
    for (size_t i = g * L; i < (g + 1) * L; ++i) {
      chmin(ans, dat[i]);
    }
    mim[g] = ans;
  }

  void add(size_t begin, size_t end, T x) {
    pay(begin / L);
    pay(end / L);
    size_t i;
    for (i = begin; i < end && i % L != 0; ++i) {
      dat[i] += x;
    }
    compute_mim(begin / L);
    for (; i + L <= end; i += L) {
      dividend[i / L] += x;
      paid[i / L] = false;
      mim[i / L] += x;
    }
    for (; i < end; ++i) {
      dat[i] += x;
    }
    compute_mim(end / L);
  }

  T find(size_t begin, size_t end) {
    pay(begin / L);
    pay(end / L);
    T ans = dat[begin];
    size_t i;
    for (i = begin; i < end && i % L != 0; ++i) {
      chmin(ans, dat[i]);
    }
    for (; i + L <= end; i += L) {
      chmin(ans, mim[i / L]);
    }
    for (; i < end; ++i) {
      chmin(ans, dat[i]);
    }
    return ans;
  }

  static size_t csqrt(size_t n) {
    size_t k = 1;
    while (k * k < n + 2) { ++k; }
    return k;
  }
};

int main() {
  // cout << fixed << setprecision(10);

  int N, Q; cin >> N >> Q;
  service<lli> srv(N, 0);
  REP(query, Q) {
    //cerr << stringify(srv.dat, srv.dividend, srv.paid, srv.mim, srv.L) << endl;
    int T; cin >> T;
    if (T == 0) {
      lli S, T, X; cin >> S >> T >> X;
      //cerr << "add: " << stringify(S, T, X) << endl;
      srv.add(S, T+1, X);
    } else {
      lli S, T; cin >> S >> T;
      //cerr << "find: " << stringify(S, T) << endl;
      cout << srv.find(S, T+1) << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3600