#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <set>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>
#include <queue>
#include <map>

#define fir first
#define sec second
#define sz(s) (s).size()
#define pb push_back
#define get(n) scanf("%d",&n);
#define gets(s) string s;cin >> (s);
#define prfi(n) printf("%d", &n);
#define prfd(n) printf("%lf", &n);
#define All(s) (s).begin(), (s).end()
#define rep(i,j) for(int (i)=0;(i)<(j);(i)++)
#define For(i,j,k) for(int (i)=(j);(i)<(k);(i)++)
#define repd(i,j) for(int (i)=(j);(i)>=0;(i)--)
#define Ford(i,j,k) for(int (i)=(j);i>=(k);i--)
#define vfor(c,v) for(auto (c): v)
#define mem(a,b) memset(a,b,sizeof(a));
#define dump(x)  std::cout << #x << " = " << (x) << std::endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using ll = long long;
using ld = long double;
using pii = std::pair<int,int>;
using pll = std::pair<ll, ll>;
using vi = std::vector<int> ;
using vvi = std::vector<vi> ;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vd = std::vector<double> ;
using vvd = std::vector<vd> ;
using qi = std::queue<int> ;
using vpii = std::vector<std::pair<int, int> >;
using vpll = std::vector<pll>;
using namespace std;

const int Mod = (1e9) + 7;
const int INF = 1e9 + 19;
const ll INFL = 1e18 + 19;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
//_____________________________________Templates_________________________________________//

template<class T1, class T2> inline void chmin(T1 &a, T2 b){if(a > b) a = b;}
template<class T1, class T2> inline void chmax(T1 &a, T2 b){if(a < b) a = b;}
template<class T> inline void swap(T &a,T &b){T c = a;a = b;b = c;}
template<class T> inline void pri(T a){cout << a << endl;}
template<class Z> using vec = vector<Z>;
//mainly use for dynamic prog
template<class T1, class T2>
void update(T1 &a, T2 b){
  a += b;
  if(a > Mod) a %= Mod;
}

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

bool pairsort(pll pl, pll pr){
  if(pl.first == pr.first)return pl.second > pr.second;
  return pl.first < pr.first;
}

int cntbit(ll a,int n,int j){int res = 0;For(i,j,n){if(a>>i & 1){res++;}}return res;}
ll makebit(ll a,int n,int j){ll res = 0;For(i,j,n){if(a &(1 << i))res |= 1ll << (i - j);}return res;}
int GCD(int a, int b){if(b > a)return GCD(b,a);if(a%b == 0)return b;else return GCD(b, a%b);}
int LCM(int a, int b){return a*b/GCD(a,b);}

//_____________________　following sorce code_________________________//
template<class Z>
struct SegTreeLazy {
  using T = Z;
  vector<T> data;
  vector<T> lazy;
  T UNIT;
  int n;
  ll s;
  SegTreeLazy(int n, T a) : n (n),UNIT(a){
    s = 1;
    while(s < n){
      s *= 2;
    }
    data = vector<T>(s*2 - 1,UNIT);
    lazy = vector<T>(s*2 - 1, UNIT);
  }
  
  void evaluate(int k, int l, int r){
    if(lazy[k] != 0){
      data[k] += lazy[k];
      if(r - l > 1){
        lazy[k*2+1] += lazy[k];
        lazy[k*2+2] += lazy[k];
      }
      lazy[k] = 0;
    }
  }

  void add(int a, int b,T x, int k=0, int l=0, int r=-1){
    if(r == -1)r = s;
    evaluate(k,l,r);
    if(b <= l || r <= a){
      return ;
    }
    if(a <= l && r <= b){
      lazy[k] += x;
      //dump(lazy[k]);
      //dump(k);
      //dump(lazy[k]);
      evaluate(k,l,r);
    }
    else {
      add(a,b,x,k*2+1,l,(r+l)/2);
      add(a,b,x,k*2+2,(l+r)/2,r);
      data[k] = min(data[k*2+1], data[k*2+2]);
      //cout << "data[" << k << "] = " << data[k] << endl;
    }
  }
  T query(int a, int b, int k=0, int l=0, int r=-1){
    if(r == -1)r = s;
    evaluate(k,l,r);
    if(r <= a || b <= l)return INF;
    if(a <= l && r <= b)return data[k];
    T vl = query(a,b,k*2+1,l,(r+l)/2);
    T vr = query(a,b,k*2+2,(l+r)/2,r);
    //dump(vl);
    //dump(vr);
    return min(vl, vr);
  }
};
const int max_n = 3 * (1e5) + 1;
const int max_m = 83 * (1e5) + 1;
int n,m,k;
vvi dp;
string S;
int a,b,c;
vi v;

int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int q;
  IN(n,q);

  SegTreeLazy<ll> sg(n, 0);
  sg.add(n+1,sg.s,INF);
  rep(i,q){
    IN(a);
    if(a == 0)
    {
      //OUT("a");
      ll x;
      IN(b,c,x);c++;
      sg.add(b,c,x);
    }
    else 
    {
      IN(b,c);c++;
      //OUT("b");
      ll ans = sg.query(b,c);
      //cout << "ans = ";
      cout << ans << endl;
    }
  }
  //for(auto c : ans){cout << c << endl;}
  //cout << fixed << setprecision(15) << ans << endl;
  return 0;
}



Measured memory_bytes: 7072