#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class Splay_Tree{
	private:
	int n;
	vi L,R,par,val,date,sub,lazy;
	inline void Fix(int k){
		if(k==n) return;
		sub[k]=sub[L[k]]+sub[R[k]]+1;
		date[k]=min(val[k],min(date[L[k]],date[R[k]])+lazy[k]);
	}
	inline void Set(int k,int l,int r,int p,bool B=0){
		if(B) swap(l,r);
		L[k]=l;R[k]=r;par[k]=p;
		if(l!=n) par[l]=k;
		if(r!=n) par[r]=k;
		Fix(k);
	}
	inline void Push(int v){
		int lv=L[v],rv=R[v],k=lazy[v];
		if(lv!=n) val[lv]+=k,lazy[lv]+=k;
		if(rv!=n) val[rv]+=k,lazy[rv]+=k;
		lazy[v]=0;Fix(lv);Fix(rv);Fix(v);
	}
	inline void Clear(int v){
		L[v]=R[v]=par[v]=n;
		val[v]=date[v]=0;
		sub[v]=1;
	}
	inline int Ch(int v,bool B){return (B?R[v]:L[v]);}
	void Rotate(int v,bool B){
		int p=par[v],u=Ch(v,B);
		Push(v);Push(u);
		Set(v,Ch(u,!B),Ch(v,!B),u,B);
		Set(u,Ch(u,B),v,p,B);
		if(p!=n) (L[p]==v?L[p]:R[p])=u;
	}
	int Splay(int u){
		while(par[u]!=n){
			int v=par[u],w=par[v];
			bool A=(R[v]==u),B=(R[w]==v);
			if(w==n){
				Rotate(v,A);
				continue;
			}
			if(A==B){swap(v,w);swap(A,B);}
			Rotate(v,A);Rotate(w,B);
		}
	}
	public:
	Splay_Tree(int N){
		n=N;
		L=R=par=vi(n+1,n);
		val=date=lazy=vi(n+1);
		sub=vi(n+1,1);
		sub[n]=0;val[n]=date[n]=inf;
		for(int i=1;i<n;i++) Set(i,i-1,n,i+1);
	}
	void Update(int k,int x){
		k=Find(0,k);
		val[k]=x;Fix(k);
	}
	int Find(int v,int k){
		Splay(v);
		while(1){
			int t=sub[L[v]];
			if(t==k) break;
			if(k<t) v=L[v];
			else k-=t+1,v=R[v];
		}
		Splay(v);
		return v;
	}
	int Sub(int v){Splay(v);return sub[v];}
	void Insert(int v,int k,int id){
		Splay(v);
		while(1){
			Push(v);
			int u=L[v],t=sub[u],B=(k>t?1:0);
			if(B) k-=t+1,u=R[v];
			if(u==n){
				(B?R[v]:L[v])=id;
				Set(id,n,n,v);
				break;
			}
			v=u;
		}
		Splay(id);
	}
	void Erase(int v,int k){
		if(!k){
			int u=Find(v,k);
			Clear(u);
		}
		int l=Find(v,k-1),r=Find(v,k);
		Splay(l);Splay(r);
		Push(r);Push(l);
		if(R[r]!=n) par[R[r]]=l;
		Set(l,L[l],R[r],n);
		Clear(r);
	}
	void Erase_id(int v){
		Splay(v);
		Erase(v,sub[L[v]]);
	}
	void Merge(int l,int r){
		r=Find(r,0);
		Splay(l);
		Push(r);
		Set(r,l,R[r],n);
	}
	int Split(int v,int k){
		if(!k||k==Sub(v)) return n;
		v=Find(v,k);
		Push(v);
		par[L[v]]=n;
		Set(v,n,R[v],n);
		return v;
	}
	int Query(int l,int r){
		l=Find(0,l);r=Find(0,r);
		Splay(l);Splay(r);
		int m=val[r];Push(r);
		while(l!=r){
			r=L[r];Push(r);
			m=min({m,val[r],date[R[r]]});
		}
		return m;
	}
	void Add(int l,int r,int x){
		l=Find(0,l);r=Find(0,r);
		Splay(l);Splay(r);
		while(l!=r){
			if(R[l]!=n) val[R[l]]+=x,lazy[R[l]]+=x;
			val[l]+=x;Fix(R[l]);Fix(l);
			l=par[l];
		}
		val[l]+=x;Fix(l);
	}
	int Value(int k){return val[Find(0,k)];}
	void Open(){
		for(int i=0;i<=n;i++) cout<<i<<':'<<L[i]<<' '<<R[i]<<' '<<par[i]<<endl;
		for(int i=0;i<n;i++) cout<<val[i]<<' ';
		cout<<endl;
		for(int i=0;i<n;i++) cout<<lazy[i]<<' ';
		cout<<endl;
		for(int i=0;i<n;i++) cout<<date[i]<<' ';
		cout<<endl;
		return;
		for(int i=0;i<n;i++){
			cout<<i<<' '<<L[i]<<' '<<0<<endl;
			cout<<i<<' '<<R[i]<<' '<<1<<endl;
			cout<<i<<' '<<par[i]<<' '<<2<<endl;
		}
	}
	bool dfs(int v,int d,int l,int r,vi& a){
		bool B=(val[v]+d==a[v]);
		if(L[v]!=n) B&=dfs(L[v],d+lazy[v],l,v-1,a);
		if(R[v]!=n) B&=dfs(R[v],d+lazy[v],v+1,r,a);
		int m=inf;
		for(int i=l;i<=r;i++) m=min(m,a[i]);
		B&=(date[v]+d==m);
		if(date[v]+d!=m) cout<<v<<' '<<l<<' '<<r<<' '<<date[v]+d<<' '<<m<<"!!!"<<endl;
		return B;
	}
	bool Check(vi a){
		int rt;
		for(int i=0;i<n;i++) if(par[i]==n) rt=i;
		return dfs(rt,0,0,n-1,a);
	}
};

int n,q;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>q;
	Splay_Tree sp(n);
	for(int i=0;i<q;i++){
		int t,l,r;
		cin>>t>>l>>r;
		if(!t){
			int x;
			cin>>x;
			sp.Add(l,r,x);
		}
		else cout<<sp.Query(l,r)<<endl;
	}
}


Measured memory_bytes: 5488