#define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

unsigned long xor128() {
  static unsigned long x=123456789, y=362436069, z=521288629, w=88675123;
  unsigned long t=(x^(x<<11));
  x=y; y=z; z=w;
  return ( w=(w^(w>>19))^(t^(t>>8)) );
}

template <class Op1, class Op2, class Op3>
class implicit_treap {
  Op1 op1;
  Op2 op2;
  Op3 op3;
  int id1;
  int id2;
  struct node_type {
    int key, acc, lazy;
    int priority, cnt;
    bool rev;
    node_type *l, *r;
    node_type(int key, int priority, int acc, int lazy)
      : key(key), acc(acc), lazy(lazy), priority(priority), cnt(1), rev(false), l(nullptr), r(nullptr)
      {}
  };
  using pointer = node_type *;
  pointer root = nullptr;

  node_type * make_node(int key) {
    return new node_type(key, xor128(), id1, id2);
  }

  int cnt(pointer t) {
    return t ? t->cnt : 0;
  }

  int get_min(pointer t) {
    return t ? t->acc : id1;
  }

  void update_cnt(pointer t) {
    if (t) {
      t->cnt = 1 + cnt(t->l) + cnt(t->r);
    }
  }

  void update_min(pointer t) {
    if (t) {
      t->acc = op1(t->key, op1(get_min(t->l), get_min(t->r)));
    }
  }

  void pushup(pointer t) {
    update_cnt(t), update_min(t);
  }

  void pushdown(pointer t) {
    if (t && t->rev) {
      t->rev = false;
      std::swap(t->l, t->r);
      if (t->l) t->l->rev ^= 1;
      if (t->r) t->r->rev ^= 1;
    }
    if (t && t->lazy) {
      if (t->l) {
        t->l->lazy += t->lazy;
        t->l->acc += t->lazy;
      }
      if (t->r) {
        t->r->lazy += t->lazy;
        t->r->acc += t->lazy;
      }
      t->key += t->lazy;
      t->lazy = 0;
    }
    pushup(t);
  }

  void split(pointer t, int key, pointer& l, pointer& r) {
    if (!t) {
      l = r = nullptr;
      return;
    }
    pushdown(t);
    int implicit_key = cnt(t->l) + 1;
    if (key < implicit_key) {
      split(t->l, key, l, t->l), r = t;
    } else {
      split(t->r, key - implicit_key, t->r, r), l = t;
    }
    pushup(t);
  }

  void insert(pointer& t, int key, pointer item) {
    pointer t1, t2;
    split(t, key, t1, t2);
    merge(t1, t1, item);
    merge(t, t1, t2);
  }

  void merge(pointer& t, pointer l, pointer r) {
    pushdown(l);
    pushdown(r);
    if (!l || !r) {
      t = l ? l : r;
    } else if (l->priority > r->priority) {
      merge(l->r, l->r, r), t = l;
    } else {
      merge(r->l, l, r->l), t = r;
    }
    pushup(t);
  }

  void erase(pointer& t, int key) {
    pointer t1, t2, t3;
    split(t, key + 1, t1, t2);
    split(t1, key, t1, t3);
    merge(t, t1, t2);
  }

  void add(pointer t, int l, int r, int x) {
    pointer t1, t2, t3;
    split(t, l, t1, t2);
    split(t2, r - l, t2 , t3);
    t2->lazy += x;
    t2->acc += x;
    merge(t2, t2, t3);
    merge(t, t1, t2);
  }

  int findmin(pointer t, int l, int r) {
    pointer t1, t2, t3;
    split(t, l, t1, t2);
    split(t2, r - l, t2, t3);
    int ret = t2->acc;
    merge(t2, t2, t3);
    merge(t, t1, t2);
    return ret;
  }

  void reverse(pointer t, int l, int r) {
    if (l > r) return;
    pointer t1, t2, t3;
    split(t, l, t1, t2);
    split(t2, r - l, t2, t3);
    t2->rev ^= 1;
    merge(t2, t2, t3);
    merge(t, t1, t2);
  }

  void rotate(pointer t, int l, int m, int r) {
    reverse(t, l, r);
    reverse(t, l, l + r - m);
    reverse(t, l + r - m, r);
  }

public:
  implicit_treap(Op1 op1, Op2 op2, Op3 op3, int id1, int id2)
    : op1(op1), op2(op2), op3(op3), id1(id1), id2(id2){}

  void insert(int pos, int x) {
    insert(root, pos, make_node(x));
  }

  void add(int l, int r, int x) {
    add(root, l, r, x);
  }

  int findmin(int l, int r) {
    return findmin(root, l, r);
  }

  void erase(int pos) {
    erase(root, pos);
  }

  void reverse(int l, int r) {
    reverse(root, l, r);
  }

  void rotate(int l, int m, int r) {
    rotate(root, l, m, r);
  }

  auto collect() {
    std::vector<int> ret;
    auto dfs = [&] (auto&&dfs, pointer t) -> void {
      if (!t) return;
      this->pushdown(t);
      dfs(dfs, t->l);
      ret.emplace_back(t->key);
      dfs(dfs, t->r);
    };
    dfs(dfs, root);
    return ret;
  }
};

template <class Op1 ,class Op2, class Op3>
auto make_implicit_treap(Op1 op1, Op2 op2, Op3 op3, int id1, int id2) {
  return implicit_treap<Op1, Op2, Op3>(op1, op2, op3, id1, id2);
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n, q; std::cin >> n >> q;
  constexpr int inf = std::numeric_limits<int>::max();
  auto treap = make_implicit_treap(
    [](int x, int y){ return std::min(x, y); },
    [](int x, int y){ return x + y; },
    [](int x, int y){ return x + y; },
    inf,
    0
  );
  loop(n) treap.insert(0,0);
  loop(q) {
    int c; std::cin >> c;
    if (c == 0) {
      int l, r, x;
      std::cin >> l >> r >> x;
      r++;
      treap.add(l,r,x);
    } else {
      int l, r; std::cin >> l >> r;
      r++;
      int ans = treap.findmin(l,r);
      std::cout << ans << std::endl;
    }
    debug(treap.collect());
  }
  return 0;
}



Measured memory_bytes: 7892