// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

template<typename T> class StarrySkyTree {
  vector<T> tree; // 1-indexed
  int size = 1;

  void build(int i) {
    while (i /= 2) {
      int x = min(tree[i * 2], tree[i * 2 + 1]);
      tree[i] += x;
      tree[i * 2] -= x;
      tree[i * 2 + 1] -= x;
    }
  }

  void reduce(deque<pair<int, T>> &q) {
    while (q.size()) {
      int i;
      T s1;
      tie(i, s1) = q.front();
      if (i == 1) break;
      q.pop_front();
      if (q.size() && q.front().first / 2 == i / 2) {
        T s2 = q.front().second;
        q.pop_front();
        q.emplace_front(i / 2, min(s1, s2) + tree[i / 2]);
      } else {
        q.emplace_front(i / 2, s1 + tree[i / 2]);
      }
    }
  }

public:
  StarrySkyTree(const int &n = 0) {
    while (size < n) size *= 2;
    tree.assign(size * 2, T());
  }

  StarrySkyTree(const int &n, const T &x) {
    while (size < n) size *= 2;
    tree.assign(size * 2, 1e9);
    fill(tree.begin() + size, tree.begin() + size + n, x);
    for (int i = size - 1; i >= 1; i--) {
      tree[i] = min(tree[i * 2], tree[i * 2 + 1]);
      tree[i * 2] -= tree[i];
      tree[i * 2 + 1] -= tree[i];
    }
  }

  T minimum(int l, int r) { // [l, r)
    deque<pair<int, T>> lq, rq;
    for (l += size, r += size; l < r; l /= 2, r /= 2) {
      if (l & 1) lq.emplace_back(l, tree[l]), l++;
      if (r & 1) --r, rq.emplace_back(r, tree[r]);
    }
    T ans = 1e9;
    if (lq.size()) reduce(lq), cmin(ans, lq.front().second);
    if (rq.size()) reduce(rq), cmin(ans, rq.front().second);
    return ans;
  }

  void add(int l, int r, const T &x) { // [l, r)
    int l0 = l += size, r0 = r += size;
    for (; l < r; l /= 2, r /= 2) {
      if (l & 1) tree[l++] += x;
      if (r & 1) tree[--r] += x;
    }
    build(l0), build(r0 - 1);
  }
};

main() {
  int n, q;
  cin >> n >> q;
  StarrySkyTree<int> sst(n, 0);
  while (q--) {
    int a, s, t;
    cin >> a >> s >> t;
    if (a) {
      cout << sst.minimum(s, t + 1) << endl;
    } else {
      sst.add(s, t + 1, in());
    }
  }
}



Measured memory_bytes: 4944