using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using static System.Math;

namespace CSharpSpiral {
	using SegmentTree;
	class Program {
		public static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush=
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			var datum = cin.ReadIntArray(2);
			int N = datum[0], Q = datum[1];
			var X = new LazySegment<long, long>(N, (i, j) => Min(i,j), int.MaxValue,
			(x, a) => a+x, (a, b) => b+a, 0,
			(x, i) => x,
			x=>x
			);
			X.RangeUpdate(0, N, -int.MaxValue);
			for(int q = 0; q<Q; q++) {
				var query = cin.ReadInt;
				var s0 = cin.ReadInt;
				var s1 = cin.ReadInt+1;
				switch(query) {
					case 0:
						var x = cin.ReadInt;
						X.RangeUpdate(s0, s1, x);
						break;
					case 1:
						var res = X.GetValue(s0, s1);
						Console.WriteLine(res);
						break;
					default:
						break;
				}
			}
		}

	}

	static class ExtendClass {
		public static string Join<T>(this IEnumerable<T> X, string separator = " ")
			=> string.Join(separator, X);
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator=separator;
			this._stream=stream;
			inputStream=new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count!=0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i<tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i<N; ++i)
				ret[i]=Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i<N; ++i) ret[i]=ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i<N; ++i) ret[i]=ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i<N; ++i) ret[i]=ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek()==-1; }
		}
	}
}

namespace SegmentTree {
	class SegmentTree<T> {
		//UI is 0-indexed, internal is 1-indexed
		public readonly int rank;
		public T[] Nodes { get; }
		public Func<T, T, T> OPER { get; }
		public T unit { get; set; }
		protected int width { get { return 1<<(rank-1); } }
		private T raise(int c) {
			return (c&1)==0
			? OPER(Nodes[c-1], Nodes[(c-1)+1]) //$c is even
			: OPER(Nodes[(c-1)-1], Nodes[c-1]); //odd
		}
		public IEnumerable<T> leafs() => Nodes.Skip(width-1);
		protected int leafIndex(int x) => (1<<(rank-1))+(x-1);
		public SegmentTree(int count, Func<T, T, T> _OPER, T _unit) {
			if(count==0) throw new ArgumentNullException();
			var last = count-1;
			rank=0;
			if(last>0) {
				while((last>>rank)>1) rank++;
				rank+=2;
			} else rank=1;
			Nodes=Enumerable.Repeat(_unit, (1<<rank)-1).ToArray();
			OPER=_OPER;
			unit=_unit;
		}
		public virtual void SetImmediate(int x, T value) {
			var r = rank-1;
			var jc = (1<<r)+x;
			Nodes[jc-1]=value;
			for(r--; r>=0; r--) {
				var parentIndex = (jc>>1)-1;
				var oldValue = Nodes[parentIndex];
				Nodes[parentIndex]=raise(jc);
				if(oldValue.Equals(Nodes[parentIndex])) break;
				jc>>=1;
			}
		}
		public virtual void ImmediateOperate<S>(int x, S value, Func<S, T, T> LeftOP) {
			SetImmediate(x, LeftOP(value, Nodes[leafIndex(x)]));
		}
		public virtual T GetValue(int start, int end) => GV(start, end, 1, 0, width);
		private T GV(int start, int end, int count, int focusStart, int focusEnd) {
			if(focusEnd<=start||end<=focusStart) return unit;
			if(start<=focusStart&&focusEnd<=end) return Nodes[count-1];
			var mid = focusStart+(focusEnd-focusStart)/2;
			return OPER(
				GV(start, end, count*2, focusStart, mid),
				GV(start, end, count*2+1, mid, focusEnd)
			);
		}
		public IEnumerable<T> GetLayer(int c) => Nodes.Skip((1<<(c-1))-1).Take(1<<(c-1));
		public IEnumerable<T> GetLeaves() => Nodes.Skip((1<<(rank-1))-1).Take(1<<(rank-1));
	}
	//https://tsutaj.hatenablog.com/entry/2017/03/30/224339
	//https://github.com/drken1215/algorithm/blob/master/DataStructure/segment_tree_delay.cpp

	/*
	var RUQRSQ = new LazySegment<long, long?>(N, (i, j) => i+j, 0,
			(x, a) => a??x, (a, b) => b??a, null,
			(x, i) => x!=null ? x*i : null,
			x=>x/2
			);
			*/
	class LazySegment<T, S>: SegmentTree<T> {
		public LazySegment(int _N, Func<T, T, T> _OPER, T _unit,
			Func<T, S, T> _ACT, Func<S, S, S> _OPER_ACT, S _unit_OPER,
			Func<S, int, S> _POWERS, Func<S, S> _SQRT
		) : base(_N, _OPER, _unit) {
			lazy=Enumerable.Repeat(_unit_OPER, Nodes.Length).ToArray();
			FA=_ACT;
			FL=_OPER_ACT;
			uo=_unit_OPER;
			Power=_POWERS;
			SQ=_SQRT;
		}
		Func<T, S, T> FA { get; }
		Func<S, S, S> FL { get; }
		Func<S, int, S> Power { get; }
		Func<S, S> SQ { get; }
		void AL(ref S sOld, S sNew) { sOld=FL(sOld, sNew); }
		void AA(ref T t, S s) { t=FA(t, s); }
		S uo { get; }
		private S[] lazy { get; }
		//k is 0-indexed
		private void eval(int k, int interval) {
			if(!lazy[k].Equals(uo)) {
				if(k+1<width) {
					AL(ref lazy[2*k+1], SQ(lazy[k]));
					AL(ref lazy[2*k+2], SQ(lazy[k]));
				}
				AA(ref Nodes[k], lazy[k]);
				lazy[k]=uo;
			}
		}
		private void RangeUpdate(int start, int end, S value,
			int nodeIdx, int focusStart, int focusEnd) {
			if(focusEnd<0) focusEnd=width;
			eval(nodeIdx, focusEnd-focusStart);
			if(end<=focusStart||focusEnd<=start) return;
			if(start<=focusStart&&focusEnd<=end) {
				AL(ref lazy[nodeIdx], Power(value, focusEnd-focusStart));
				eval(nodeIdx, focusEnd-focusStart);
			} else {
				var midFocus = (focusStart+focusEnd)/2;
				RangeUpdate(start, end, value, 2*nodeIdx+1, focusStart, midFocus);
				RangeUpdate(start, end, value, 2*nodeIdx+2, midFocus, focusEnd);
				Nodes[nodeIdx]=OPER(Nodes[2*nodeIdx+1], Nodes[2*nodeIdx+2]);
			}
		}
		public void RangeUpdate(int start, int end, S value) => RangeUpdate(start, end, value, 0, 0, -1);
		public override T GetValue(int start, int end) {
			return GetValue(start, end, 0, 0, -1);
		}
		private T GetValue(int start, int end,
			int nodeIdx, int focusStart, int focusEnd) {
			if(focusEnd<0) focusEnd=width;
			eval(nodeIdx, focusEnd-focusStart);
			if(end<=focusStart||focusEnd<=start) return unit;
			if(start<=focusStart&&focusEnd<=end)
				return Nodes[nodeIdx];
			var midFocus = (focusStart+focusEnd)/2;
			var leftV = GetValue(start, end, 2*nodeIdx+1, focusStart, midFocus);
			var rightV = GetValue(start, end, 2*nodeIdx+2, midFocus, focusEnd);
			return OPER(leftV, rightV);
		}
	}

}


Measured memory_bytes: 34720